Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: spear: plgpio: Introduce regmap phandle

Resources need to be shared between pinmux and plgpio.

Introduce regmap phandle in order to retrieve the regmap
from the phandle if the property is present.
This allows to retrieve an external regmap (ie the one
used by pinmux if the phandle references the pinmux node)
from plgpio.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20211202095255.165797-4-herve.codina@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Herve Codina and committed by
Linus Walleij
1288cadc 7151cef5

+17 -5
+17 -5
drivers/pinctrl/spear/pinctrl-plgpio.c
··· 523 523 524 524 static int plgpio_probe(struct platform_device *pdev) 525 525 { 526 + struct device_node *regmap_np; 526 527 struct plgpio *plgpio; 527 528 int ret, irq; 528 529 ··· 531 530 if (!plgpio) 532 531 return -ENOMEM; 533 532 534 - plgpio->regmap = device_node_to_regmap(pdev->dev.of_node); 535 - if (IS_ERR(plgpio->regmap)) { 536 - dev_err(&pdev->dev, "Init regmap failed (%pe)\n", 537 - plgpio->regmap); 538 - return PTR_ERR(plgpio->regmap); 533 + regmap_np = of_parse_phandle(pdev->dev.of_node, "regmap", 0); 534 + if (regmap_np) { 535 + plgpio->regmap = device_node_to_regmap(regmap_np); 536 + of_node_put(regmap_np); 537 + if (IS_ERR(plgpio->regmap)) { 538 + dev_err(&pdev->dev, "Retrieve regmap failed (%pe)\n", 539 + plgpio->regmap); 540 + return PTR_ERR(plgpio->regmap); 541 + } 542 + } else { 543 + plgpio->regmap = device_node_to_regmap(pdev->dev.of_node); 544 + if (IS_ERR(plgpio->regmap)) { 545 + dev_err(&pdev->dev, "Init regmap failed (%pe)\n", 546 + plgpio->regmap); 547 + return PTR_ERR(plgpio->regmap); 548 + } 539 549 } 540 550 541 551 ret = plgpio_probe_dt(pdev, plgpio);