Skip to contentSkip to conversation

Get rid of [devm_]gpiod_get_from_of_node() public APIs

PATCH Applied Dmitry Torokhov 10 participants 61 messages Sep 5, 2022 – Oct 28, 2022

Subsystems (17)
lore
Share & tools
lore
#0 lore raw

cover Get rid of [devm_]gpiod_get_from_of_node() public APIs

I would like to stop exporting OF-specific [devm_]gpiod_get_from_of_node() so that gpiolib can be cleaned a bit. We can do that by switching drivers to use generic fwnode API ([devm_]fwnode_gpiod_get()). By doing so we open the door to augmenting device tree and ACPI information through secondary software properties (once we teach gpiolib how to handle those).

I hope that relevant maintainers will take patches through their trees and then we could merge the last one some time after -rc1.

---
Dmitry Torokhov (11):
PCI: tegra: switch to using devm_fwnode_gpiod_get drm/tegra: switch to using devm_fwnode_gpiod_get
mtd: rawnand: stm32_fmc2: switch to using devm_fwnode_gpiod_get()
usb: phy: tegra: switch to using devm_gpiod_get()
usb: gadget: udc: at91: switch to using fwnode_gpiod_get_index()
PCI: aardvark: switch to using devm_gpiod_get_optional()
PCI: apple: switch to using fwnode_gpiod_get_index()
regulator: bd71815: switch to using devm_fwnode_gpiod_get()
regulator: bd9576: switch to using devm_fwnode_gpiod_get()
watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()
gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs

 drivers/gpio/gpiolib-devres.c          | 55 ----------------------------------
 drivers/gpio/gpiolib-of.c              |  1 -
 drivers/gpio/gpiolib-of.h              | 13 ++++++++
 drivers/gpu/drm/tegra/output.c         | 10 +++----
 drivers/mtd/nand/raw/stm32_fmc2_nand.c |  5 ++--
 drivers/pci/controller/pci-aardvark.c  | 23 +++++++-------
 drivers/pci/controller/pci-tegra.c     |  9 +++---
 drivers/pci/controller/pcie-apple.c    |  4 +--
 drivers/regulator/bd71815-regulator.c  |  7 ++---
 drivers/regulator/bd9576-regulator.c   | 17 ++++++-----
 drivers/usb/gadget/udc/at91_udc.c      |  8 +++--
 drivers/usb/phy/phy-tegra-usb.c        | 14 ++++++---
 drivers/watchdog/bd9576_wdt.c          | 51 ++++++++++++++++++-------------
 include/linux/gpio/consumer.h          | 48 -----------------------------
 14 files changed, 96 insertions(+), 169 deletions(-)

---
base-commit: 7fd22855300e693668c3397771b3a2b3948f827a
change-id: 20220903-gpiod_get_from_of_node-remove-de3032fc01de

Best regards,

Signature · 1 line
Dmitry
#1 lore raw

PATCH 1/11 PCI: tegra: switch to using devm_fwnode_gpiod_get

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API. It may even help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

drivers/pci/controller/pci-tegra.c +5 -4
index 8e323e93be91..929f9363e94b 100644
@@ -2202,10 +2202,11 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 		 * and in this case fall back to using AFI per port register
 		 * to toggle PERST# SFIO line.
 		 */
-		rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
-							     "reset-gpios", 0,
-							     GPIOD_OUT_LOW,
-							     label);
+		rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+						       of_fwnode_handle(port),
+						       "reset",
+						       GPIOD_OUT_LOW,
+						       label);
 		if (IS_ERR(rp->reset_gpio)) {
 			if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
 				rp->reset_gpio = NULL;
Signature · 1 line
b4 0.10.0-dev-fc921
maintainer
#2 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

Quoted 15 lines · On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API. It may even help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

drivers/pci/controller/pci-tegra.c +0 -0
index 8e323e93be91..929f9363e94b 100644
@@ -2202,10 +2202,11 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 		 * and in this case fall back to using AFI per port register
 		 * to toggle PERST# SFIO line.

drivers/pci/controller/pci-tegra.c static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) · line 2209

Quoted 10 lines
drivers/pci/controller/pci-tegra.c +5 -4
 		 */
-		rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
-							     "reset-gpios", 0,
-							     GPIOD_OUT_LOW,
-							     label);
+		rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+						       of_fwnode_handle(port),
+						       "reset",
+						       GPIOD_OUT_LOW,
+						       label);

Why in pci-aardvark.c for PERST# reset-gpio you have used devm_gpiod_get_optional() and here in pci-tegra.c you have used devm_fwnode_gpiod_get()? I think that PERST# logic is same in both drivers.

Quoted 6 lines
drivers/pci/controller/pci-tegra.c +0 -0
 		if (IS_ERR(rp->reset_gpio)) {
 			if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
 				rp->reset_gpio = NULL;
Signature · 2 lines
-- 
b4 0.10.0-dev-fc921
#3 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

Quoted 1 line · Pali Rohár

On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:

...

Quoted 10 lines

drivers/pci/controller/pci-tegra.c static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) · line 2209

Quoted 9 lines
drivers/pci/controller/pci-tegra.c +5 -4
-             rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
-                                                          "reset-gpios", 0,
-                                                          GPIOD_OUT_LOW,
-                                                          label);
+             rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+                                                    of_fwnode_handle(port),
+                                                    "reset",
+                                                    GPIOD_OUT_LOW,
+                                                    label);
Quoted 4 lines

Why in pci-aardvark.c for PERST# reset-gpio you have used devm_gpiod_get_optional() and here in pci-tegra.c you have used devm_fwnode_gpiod_get()? I think that PERST# logic is same in both drivers.

It's not the same dev and its node in this case. There is one reset for _all_ ports, here is the reset on _per port_ basis.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

Quoted 15 lines · On Monday 05 September 2022 13:49:21 Andy Shevchenko wrote:
Quoted 1 line · Pali Rohár

On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:

...

Quoted 10 lines
Quoted 9 lines
drivers/pci/controller/pci-tegra.c +5 -4
-             rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
-                                                          "reset-gpios", 0,
-                                                          GPIOD_OUT_LOW,
-                                                          label);
+             rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+                                                    of_fwnode_handle(port),
+                                                    "reset",
+                                                    GPIOD_OUT_LOW,
+                                                    label);
Quoted 7 lines
Quoted 4 lines

Why in pci-aardvark.c for PERST# reset-gpio you have used devm_gpiod_get_optional() and here in pci-tegra.c you have used devm_fwnode_gpiod_get()? I think that PERST# logic is same in both drivers.

It's not the same dev and its node in this case. There is one reset for _all_ ports, here is the reset on _per port_ basis.

aardvark is single port controller. So it is basically same.

#5 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

Quoted 1 line · Pali Rohár

On Monday 05 September 2022 13:49:21 Andy Shevchenko wrote:

...

Quoted 4 lines
Quoted 2 lines

It's not the same dev and its node in this case. There is one reset for _all_ ports, here is the reset on _per port_ basis.

aardvark is single port controller. So it is basically same.

Yep, just replied to my message.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

In reply to Andy Shevchenko
Quoted 16 lines · Andy Shevchenko
Quoted 1 line · Pali Rohár

On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:

...

Quoted 10 lines
Quoted 9 lines
drivers/pci/controller/pci-tegra.c +5 -4
-             rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
-                                                          "reset-gpios", 0,
-                                                          GPIOD_OUT_LOW,
-                                                          label);
+             rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+                                                    of_fwnode_handle(port),
+                                                    "reset",
+                                                    GPIOD_OUT_LOW,
+                                                    label);
Quoted 7 lines
Quoted 4 lines

Why in pci-aardvark.c for PERST# reset-gpio you have used devm_gpiod_get_optional() and here in pci-tegra.c you have used devm_fwnode_gpiod_get()? I think that PERST# logic is same in both drivers.

It's not the same dev and its node in this case. There is one reset for _all_ ports, here is the reset on _per port_ basis.

Actually I'm wrong, the aardvark has only one port (?) to serve there. In any case, here dev == dev->of_node, here dev != port.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

In reply to Pali Rohár
Quoted 23 lines · Pali Rohár
Quoted 22 lines · On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API. It may even help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

drivers/pci/controller/pci-tegra.c +2 -4
index 8e323e93be91..929f9363e94b 100644
@@ -2202,10 +2202,11 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 		 * and in this case fall back to using AFI per port register
 		 * to toggle PERST# SFIO line.
 		 */
-		rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
-							     "reset-gpios", 0,
-							     GPIOD_OUT_LOW,
-							     label);
+		rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+						       of_fwnode_handle(port),
Quoted 8 lines

drivers/pci/controller/pci-tegra.c static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) · line 2209

Quoted 3 lines
drivers/pci/controller/pci-tegra.c +3 -0
+						       "reset",
+						       GPIOD_OUT_LOW,
+						       label);

Why in pci-aardvark.c for PERST# reset-gpio you have used devm_gpiod_get_optional() and here in pci-tegra.c you have used devm_fwnode_gpiod_get()? I think that PERST# logic is same in both drivers.

I believe Andy already answered that, but in this driver we can have several root ports described via subnodes of dev->of_node, and reset GPIOs are attached to those subnodes. We are forced to use devm_fwnode_gpiod_get() instead of devm_gpiod_get_optional() as we need to supply the exact fwnode we need to look up GPIO in, and can not infer it from the 'dev' parameter of devm_gpiod_get().

Thanks.

Signature · 1 line
Dmitry
Reviewed-by on v1 1/11
#8 lore raw

Re: [PATCH v1 01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API. It may even help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

Yours,
Linus Walleij

#9 lore raw

PATCH 2/11 drm/tegra: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API. It may even help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

drivers/gpu/drm/tegra/output.c +5 -5
index 47d26b5d9945..a8925dcd7edd 100644
@@ -133,11 +133,11 @@ int tegra_output_probe(struct tegra_output *output)
 		}
 	}
 
-	output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev,
-						       output->of_node,
-						       "nvidia,hpd-gpio", 0,
-						       GPIOD_IN,
-						       "HDMI hotplug detect");
+	output->hpd_gpio = devm_fwnode_gpiod_get(output->dev,
+					of_fwnode_handle(output->of_node),
+					"nvidia,hpd",
+					GPIOD_IN,
+					"HDMI hotplug detect");
 	if (IS_ERR(output->hpd_gpio)) {
 		if (PTR_ERR(output->hpd_gpio) != -ENOENT)
 			return PTR_ERR(output->hpd_gpio);
Signature · 1 line
b4 0.10.0-dev-fc921
#10 lore raw

Re: [PATCH v1 02/11] drm/tegra: switch to using devm_fwnode_gpiod_get

Quoted 8 lines · Dmitry Torokhov

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

It may even
help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

I would remove this sentence from all commit messages since it's a debatable thing and might even not happen, so the above is a pure speculation.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH v1 02/11] drm/tegra: switch to using devm_fwnode_gpiod_get

Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Dmitry Torokhov

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

Quoted 7 lines
Quoted 3 lines

It may even
help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

I would remove this sentence from all commit messages since it's a debatable thing and might even not happen, so the above is a pure speculation.

I have the patches. Granted, I had them since '19 ;) but I'm rebasing them and going to push them. I need them to convert bunch of input drivers away from platform data.

Thanks.

Signature · 1 line
Dmitry
#12 lore raw

Re: [PATCH v1 02/11] drm/tegra: switch to using devm_fwnode_gpiod_get

Quoted 12 lines · Dmitry Torokhov
Quoted 11 lines · Andy Shevchenko
Quoted 8 lines · Dmitry Torokhov

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

It may even
help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

Quoted 7 lines
Quoted 3 lines

I would remove this sentence from all commit messages since it's a debatable thing and might even not happen, so the above is a pure speculation.

I have the patches. Granted, I had them since '19 ;) but I'm rebasing them and going to push them. I need them to convert bunch of input drivers away from platform data.

That's good news!

Are you referring to this patch set mentioned in a discussion from 2017 thru 2020?
https://lore.kernel.org/linux-input/20200826161222.GA1665100@dtor-ws/

I put aside GPIO descriptor conversion for input devices (keys, buttons) in board files anticipating a swnode mechanism.

Yours,
Linus Walleij

#13 lore raw

Re: [PATCH v1 02/11] drm/tegra: switch to using devm_fwnode_gpiod_get

Quoted 22 lines · Linus Walleij
Quoted 12 lines · Dmitry Torokhov
Quoted 11 lines · Andy Shevchenko
Quoted 8 lines · Dmitry Torokhov

I would like to limit (or maybe even remove) use of [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

It may even
help with handling secondary fwnodes when gpiolib is taught to handle gpios described by swnodes.

Quoted 7 lines
Quoted 3 lines

I would remove this sentence from all commit messages since it's a debatable thing and might even not happen, so the above is a pure speculation.

I have the patches. Granted, I had them since '19 ;) but I'm rebasing them and going to push them. I need them to convert bunch of input drivers away from platform data.

Quoted 8 lines

That's good news!

Are you referring to this patch set mentioned in a discussion from 2017 thru 2020?
https://lore.kernel.org/linux-input/20200826161222.GA1665100@dtor-ws/

I put aside GPIO descriptor conversion for input devices (keys, buttons) in board files anticipating a swnode mechanism.

Yep, that one, exactly. It is taking a bit longer than I anticipated ;)

Thanks.

Signature · 1 line
Dmitry
#14 lore raw

PATCH 3/11 mtd: rawnand: stm32_fmc2: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

drivers/mtd/nand/raw/stm32_fmc2_nand.c +2 -3
index 87c1c7dd97eb..7e466b840368 100644
@@ -1799,9 +1799,8 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc,
 		nand->cs_used[i] = cs;
 	}
 
-	nand->wp_gpio = devm_gpiod_get_from_of_node(nfc->dev, dn,
-						    "wp-gpios", 0,
-						    GPIOD_OUT_HIGH, "wp");
+	nand->wp_gpio = devm_fwnode_gpiod_get(nfc->dev, of_fwnode_handle(dn),
+					      "wp", GPIOD_OUT_HIGH, "wp");
 	if (IS_ERR(nand->wp_gpio)) {
 		ret = PTR_ERR(nand->wp_gpio);
 		if (ret != -ENOENT)
Signature · 1 line
b4 0.10.0-dev-fc921
#16 lore raw

PATCH 4/11 usb: phy: tegra: switch to using devm_gpiod_get()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO, and we now have a special API for that.

drivers/usb/phy/phy-tegra-usb.c +10 -4
index 68cd4b68e3a2..f0240107edb1 100644
@@ -1440,16 +1440,22 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
 			return err;
 		}
 
-		gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-						    "nvidia,phy-reset-gpio",
-						    0, GPIOD_OUT_HIGH,
-						    "ulpi_phy_reset_b");
+		gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+				       GPIOD_OUT_HIGH);
 		err = PTR_ERR_OR_ZERO(gpiod);
 		if (err) {
 			dev_err(&pdev->dev,
 				"Request failed for reset GPIO: %d\n", err);
 			return err;
 		}
+
+		err = gpiod_set_consumer_name(gpiod, "ulpi_phy_reset_b");
+		if (err) {
+			dev_err(&pdev->dev,
+				"Failed to set up reset GPIO name: %d\n", err);
+			return err;
+		}
+
 		tegra_phy->reset_gpio = gpiod;
 
 		phy = devm_otg_ulpi_create(&pdev->dev,
Signature · 1 line
b4 0.10.0-dev-fc921
#17 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 9 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO, and we now have a special API for that.

...

drivers/usb/phy/phy-tegra-usb.c static int tegra_usb_phy_probe(struct platform_device *pdev) · line 1445

Quoted 7 lines
drivers/usb/phy/phy-tegra-usb.c +2 -4
-               gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-                                                   "nvidia,phy-reset-gpio",
-                                                   0, GPIOD_OUT_HIGH,
-                                                   "ulpi_phy_reset_b");
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                err = PTR_ERR_OR_ZERO(gpiod);

What does _OR_ZERO mean now?

Quoted 5 lines
                if (err) {
                        dev_err(&pdev->dev,
                                "Request failed for reset GPIO: %d\n", err);
                        return err;
                }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#18 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 22 lines · Andy Shevchenko
Quoted 9 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO, and we now have a special API for that.

...

drivers/usb/phy/phy-tegra-usb.c static int tegra_usb_phy_probe(struct platform_device *pdev) · line 1445

Quoted 7 lines
drivers/usb/phy/phy-tegra-usb.c +2 -4
-               gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-                                                   "nvidia,phy-reset-gpio",
-                                                   0, GPIOD_OUT_HIGH,
-                                                   "ulpi_phy_reset_b");
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                err = PTR_ERR_OR_ZERO(gpiod);
Quoted 1 line

What does _OR_ZERO mean now?

This converts a pointer to an error code if a pointer represents ERR_PTR() encoded error, or 0 to indicate success.

static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)

{
	if (IS_ERR(ptr))
		return PTR_ERR(ptr);
	else
		return 0;
}

Thanks.

Signature · 1 line
Dmitry
#19 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:32 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/usb/phy/phy-tegra-usb.c +2 -4
-               gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-                                                   "nvidia,phy-reset-gpio",
-                                                   0, GPIOD_OUT_HIGH,
-                                                   "ulpi_phy_reset_b");
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                err = PTR_ERR_OR_ZERO(gpiod);
Quoted 4 lines
Quoted 1 line

What does _OR_ZERO mean now?

This converts a pointer to an error code if a pointer represents ERR_PTR() encoded error, or 0 to indicate success.

Yes, I know that. My point is, how is it useful now (or even before)? I mean that devm_gpio_get() never returns NULL, right?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#20 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 16 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:32 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/usb/phy/phy-tegra-usb.c +2 -4
-               gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-                                                   "nvidia,phy-reset-gpio",
-                                                   0, GPIOD_OUT_HIGH,
-                                                   "ulpi_phy_reset_b");
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                err = PTR_ERR_OR_ZERO(gpiod);
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

What does _OR_ZERO mean now?

This converts a pointer to an error code if a pointer represents ERR_PTR() encoded error, or 0 to indicate success.

Yes, I know that. My point is, how is it useful now (or even before)? I mean that devm_gpio_get() never returns NULL, right?

What does returning NULL have to do with anything. It converts a pointer to a "classic" return code, with negative errors and 0 on success.

It allows to not use multiple IS_ERR/PTR_ERR in the code (I'd need 1 IS_ERR and 2 PTR_ERR, one in dev_err() and another to return).

Thanks.

Signature · 1 line
Dmitry
#21 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 6 lines · Dmitry Torokhov
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:32 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

drivers/usb/phy/phy-tegra-usb.c static int tegra_usb_phy_probe(struct platform_device *pdev) · line 1445

Quoted 7 lines
drivers/usb/phy/phy-tegra-usb.c +2 -4
-               gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-                                                   "nvidia,phy-reset-gpio",
-                                                   0, GPIOD_OUT_HIGH,
-                                                   "ulpi_phy_reset_b");
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                err = PTR_ERR_OR_ZERO(gpiod);

What does _OR_ZERO mean now?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This converts a pointer to an error code if a pointer represents ERR_PTR() encoded error, or 0 to indicate success.

Yes, I know that. My point is, how is it useful now (or even before)? I mean that devm_gpio_get() never returns NULL, right?

What does returning NULL have to do with anything.

It has to do with a dead code. If defm_gpiod_get() does not return NULL, then why do we even bother to check?

Quoted 5 lines

It converts a pointer
to a "classic" return code, with negative errors and 0 on success.

It allows to not use multiple IS_ERR/PTR_ERR in the code (I'd need 1 IS_ERR and 2 PTR_ERR, one in dev_err() and another to return).

I don't see how this is relevant.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#22 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 24 lines · Andy Shevchenko
Quoted 6 lines · Dmitry Torokhov
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:32 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 9 lines

drivers/usb/phy/phy-tegra-usb.c static int tegra_usb_phy_probe(struct platform_device *pdev) · line 1445

Quoted 7 lines
drivers/usb/phy/phy-tegra-usb.c +2 -4
-               gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
-                                                   "nvidia,phy-reset-gpio",
-                                                   0, GPIOD_OUT_HIGH,
-                                                   "ulpi_phy_reset_b");
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                 err = PTR_ERR_OR_ZERO(gpiod);

What does _OR_ZERO mean now?

This converts a pointer to an error code if a pointer represents ERR_PTR() encoded error, or 0 to indicate success.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Yes, I know that. My point is, how is it useful now (or even before)? I mean that devm_gpio_get() never returns NULL, right?

What does returning NULL have to do with anything.

It has to do with a dead code. If defm_gpiod_get() does not return NULL, then why do we even bother to check?

PTR_ERR_OR_ZERO() converts into an error code (if the pointer is an ERR_PTR) or 0 if it is a real pointer. Its purpose is not to convert NULL into 0, its purpose is to convert a pointer either into an error code or 0. That is what is done here, and it is done all over the place in the kernel. I don't see your problem with it. Care to explain ?

Quoted 8 lines
Quoted 5 lines

It converts a pointer
to a "classic" return code, with negative errors and 0 on success.

It allows to not use multiple IS_ERR/PTR_ERR in the code (I'd need 1 IS_ERR and 2 PTR_ERR, one in dev_err() and another to return).

I don't see how this is relevant.

You lost me. Really, please explain your problem with PTR_ERR_OR_ZERO().

Thanks,
Guenter

#23 lore raw

Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get()

Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Dmitry Torokhov
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:32 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+               gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset",
+                                      GPIOD_OUT_HIGH);
                 err = PTR_ERR_OR_ZERO(gpiod);

What does _OR_ZERO mean now?

This converts a pointer to an error code if a pointer represents ERR_PTR() encoded error, or 0 to indicate success.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Yes, I know that. My point is, how is it useful now (or even before)? I mean that devm_gpio_get() never returns NULL, right?

What does returning NULL have to do with anything.

It has to do with a dead code. If defm_gpiod_get() does not return NULL, then why do we even bother to check?

PTR_ERR_OR_ZERO() converts into an error code (if the pointer is an ERR_PTR) or 0 if it is a real pointer. Its purpose is not to convert NULL into 0, its purpose is to convert a pointer either into an error code or 0. That is what is done here, and it is done all over the place in the kernel. I don't see your problem with it. Care to explain ?

Quoted 3 lines
Quoted 3 lines

It converts a pointer
to a "classic" return code, with negative errors and 0 on success.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

It allows to not use multiple IS_ERR/PTR_ERR in the code (I'd need 1 IS_ERR and 2 PTR_ERR, one in dev_err() and another to return).

I don't see how this is relevant.

You lost me. Really, please explain your problem with PTR_ERR_OR_ZERO().

I don't know what I was thinking about... You, guys, are right, sorry for my noise.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#24 lore raw

PATCH 5/11 usb: gadget: udc: at91: switch to using fwnode_gpiod_get_index()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

drivers/usb/gadget/udc/at91_udc.c +5 -3
index 728987280373..1db1dbbab79a 100644
@@ -1779,12 +1779,14 @@ static void at91udc_of_init(struct at91_udc *udc, struct device_node *np)
 	if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
 		board->vbus_polled = 1;
 
-	board->vbus_pin = gpiod_get_from_of_node(np, "atmel,vbus-gpio", 0,
-						 GPIOD_IN, "udc_vbus");
+	board->vbus_pin = fwnode_gpiod_get_index(of_fwnode_handle(np),
+						 "atmel,vbus", 0, GPIOD_IN,
+						 "udc_vbus");
 	if (IS_ERR(board->vbus_pin))
 		board->vbus_pin = NULL;
 
-	board->pullup_pin = gpiod_get_from_of_node(np, "atmel,pullup-gpio", 0,
+	board->pullup_pin = fwnode_gpiod_get_index(of_fwnode_handle(np),
+						   "atmel,pullup", 0,
 						   GPIOD_ASIS, "udc_pullup");
 	if (IS_ERR(board->pullup_pin))
 		board->pullup_pin = NULL;
Signature · 1 line
b4 0.10.0-dev-fc921
#25 lore raw

PATCH 6/11 PCI: aardvark: switch to using devm_gpiod_get_optional()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO, and we now have a special API for that.

drivers/pci/controller/pci-aardvark.c +11 -12
index 4834198cc86b..4a8a4a8522cb 100644
@@ -1856,20 +1856,19 @@ static int advk_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
-						       "reset-gpios", 0,
-						       GPIOD_OUT_LOW,
-						       "pcie1-reset");
+	pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	ret = PTR_ERR_OR_ZERO(pcie->reset_gpio);
 	if (ret) {
-		if (ret == -ENOENT) {
-			pcie->reset_gpio = NULL;
-		} else {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "Failed to get reset-gpio: %i\n",
-					ret);
-			return ret;
-		}
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get reset-gpio: %i\n",
+				ret);
+		return ret;
+	}
+
+	ret = gpiod_set_consumer_name(pcie->reset_gpio, "pcie1-reset");
+	if (ret) {
+		dev_err(dev, "Failed to set reset gpio name: %d\n", ret);
+		return ret;
 	}
 
 	ret = of_pci_get_max_link_speed(dev->of_node);
Signature · 1 line
b4 0.10.0-dev-fc921
maintainer
#26 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

Quoted 7 lines · On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote:

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO,

IIRC consumer name is not used at all.

The reason was to specify full name of DTS property, for easier identification of the code. DTS property is "reset-gpios" but API specify only "reset".

Quoted 43 lines

and we now have a special API for that.

drivers/pci/controller/pci-aardvark.c +11 -12
index 4834198cc86b..4a8a4a8522cb 100644
@@ -1856,20 +1856,19 @@ static int advk_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
-						       "reset-gpios", 0,
-						       GPIOD_OUT_LOW,
-						       "pcie1-reset");
+	pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	ret = PTR_ERR_OR_ZERO(pcie->reset_gpio);
 	if (ret) {
-		if (ret == -ENOENT) {
-			pcie->reset_gpio = NULL;
-		} else {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "Failed to get reset-gpio: %i\n",
-					ret);
-			return ret;
-		}
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get reset-gpio: %i\n",
+				ret);
+		return ret;
+	}
+
+	ret = gpiod_set_consumer_name(pcie->reset_gpio, "pcie1-reset");
+	if (ret) {
+		dev_err(dev, "Failed to set reset gpio name: %d\n", ret);
+		return ret;
 	}
 
 	ret = of_pci_get_max_link_speed(dev->of_node);
Signature · 2 lines
-- 
b4 0.10.0-dev-fc921
#27 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

Quoted 10 lines · Pali Rohár
Quoted 7 lines · On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote:

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO,

IIRC consumer name is not used at all.

It's. The user space tools use it as a label. So, GPIO line can have "name" (this is provider specific) and "label" (which is consumer specific, i.o.w. how we use this line).

...

Quoted 4 lines

drivers/pci/controller/pci-aardvark.c static int advk_pcie_probe(struct platform_device *pdev) · line 1865

Quoted 4 lines
drivers/pci/controller/pci-aardvark.c +4 -0
+             if (ret != -EPROBE_DEFER)
+                     dev_err(dev, "Failed to get reset-gpio: %i\n",
+                             ret);
+             return ret;

I understand that in the input subsystem maintainer's hat you don't like dev_err_probe(), but it's a good case to have it here.

...

Quoted 5 lines

drivers/pci/controller/pci-aardvark.c static int advk_pcie_probe(struct platform_device *pdev) · line 1872

Quoted 5 lines
drivers/pci/controller/pci-aardvark.c +4 -0
+     ret = gpiod_set_consumer_name(pcie->reset_gpio, "pcie1-reset");
+     if (ret) {
+             dev_err(dev, "Failed to set reset gpio name: %d\n", ret);
+             return ret;
      }

Ditto.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#28 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

Quoted 18 lines · Andy Shevchenko
Quoted 10 lines · Pali Rohár
Quoted 7 lines · On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote:

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO,

IIRC consumer name is not used at all.

It's. The user space tools use it as a label. So, GPIO line can have "name" (this is provider specific) and "label" (which is consumer specific, i.o.w. how we use this line).

...

Quoted 7 lines
Quoted 4 lines

drivers/pci/controller/pci-aardvark.c static int advk_pcie_probe(struct platform_device *pdev) · line 1865

Quoted 4 lines
drivers/pci/controller/pci-aardvark.c +4 -0
+             if (ret != -EPROBE_DEFER)
+                     dev_err(dev, "Failed to get reset-gpio: %i\n",
+                             ret);
+             return ret;

I understand that in the input subsystem maintainer's hat you don't like dev_err_probe(), but it's a good case to have it here.

The driver currently does not use this API, so I elected not to introduce it in this series.

Thanks,

Signature · 1 line
Dmitry
#29 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

In reply to Pali Rohár
Quoted 9 lines · Pali Rohár
Quoted 7 lines · On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote:

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO,

Quoted 5 lines

IIRC consumer name is not used at all.

The reason was to specify full name of DTS property, for easier identification of the code. DTS property is "reset-gpios" but API specify only "reset".

I see. Do you want me to reset the patch with updated desctiption as to the reason devm_gpiod_get_from_of_node() was used?

Quoted 40 lines
Quoted 40 lines

and we now have a special API for that.

drivers/pci/controller/pci-aardvark.c +11 -12
index 4834198cc86b..4a8a4a8522cb 100644
@@ -1856,20 +1856,19 @@ static int advk_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
-						       "reset-gpios", 0,
-						       GPIOD_OUT_LOW,
-						       "pcie1-reset");
+	pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	ret = PTR_ERR_OR_ZERO(pcie->reset_gpio);
 	if (ret) {
-		if (ret == -ENOENT) {
-			pcie->reset_gpio = NULL;
-		} else {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "Failed to get reset-gpio: %i\n",
-					ret);
-			return ret;
-		}
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get reset-gpio: %i\n",
+				ret);
+		return ret;
+	}
+
+	ret = gpiod_set_consumer_name(pcie->reset_gpio, "pcie1-reset");
+	if (ret) {
+		dev_err(dev, "Failed to set reset gpio name: %d\n", ret);
+		return ret;
 	}
 
Quoted 4 lines
Quoted 4 lines
drivers/pci/controller/pci-aardvark.c +0 -0
 	ret = of_pci_get_max_link_speed(dev->of_node);
Signature · 2 lines
-- 
b4 0.10.0-dev-fc921

Thanks.

Signature · 1 line
Dmitry
maintainer Acked-by
#30 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

Quoted 10 lines · On Monday 05 September 2022 15:54:53 Dmitry Torokhov wrote:
Quoted 9 lines · Pali Rohár
Quoted 7 lines · On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote:

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO,

Quoted 8 lines
Quoted 5 lines

IIRC consumer name is not used at all.

The reason was to specify full name of DTS property, for easier identification of the code. DTS property is "reset-gpios" but API specify only "reset".

I see. Do you want me to reset the patch with updated desctiption as to the reason devm_gpiod_get_from_of_node() was used?

I think it is fine. So add my:

Anyway as another improvement for future I would suggest some API function with _optional_ logic, so it could be used for more PCIe controller drivers (e.g. also tegra) without need to reimplement -ENOENT handling. It is really strange if for acquiring same PERST# line via GPIO ("reset-gpios" DT property) are used more API functions in different PCIe drivers.

Quoted 49 lines
Quoted 40 lines
Quoted 40 lines

and we now have a special API for that.

drivers/pci/controller/pci-aardvark.c +11 -12
index 4834198cc86b..4a8a4a8522cb 100644
@@ -1856,20 +1856,19 @@ static int advk_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
-						       "reset-gpios", 0,
-						       GPIOD_OUT_LOW,
-						       "pcie1-reset");
+	pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	ret = PTR_ERR_OR_ZERO(pcie->reset_gpio);
 	if (ret) {
-		if (ret == -ENOENT) {
-			pcie->reset_gpio = NULL;
-		} else {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "Failed to get reset-gpio: %i\n",
-					ret);
-			return ret;
-		}
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get reset-gpio: %i\n",
+				ret);
+		return ret;
+	}
+
+	ret = gpiod_set_consumer_name(pcie->reset_gpio, "pcie1-reset");
+	if (ret) {
+		dev_err(dev, "Failed to set reset gpio name: %d\n", ret);
+		return ret;
 	}
 
Quoted 4 lines
Quoted 4 lines
drivers/pci/controller/pci-aardvark.c +0 -0
 	ret = of_pci_get_max_link_speed(dev->of_node);
Signature · 2 lines
-- 
b4 0.10.0-dev-fc921

Thanks.

Signature · 1 line
Dmitry
#31 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

Quoted 20 lines · Pali Rohár
Quoted 10 lines · On Monday 05 September 2022 15:54:53 Dmitry Torokhov wrote:
Quoted 9 lines · Pali Rohár
Quoted 7 lines · On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote:

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO,

Quoted 8 lines
Quoted 5 lines

IIRC consumer name is not used at all.

The reason was to specify full name of DTS property, for easier identification of the code. DTS property is "reset-gpios" but API specify only "reset".

I see. Do you want me to reset the patch with updated desctiption as to the reason devm_gpiod_get_from_of_node() was used?

Quoted 6 lines

I think it is fine. So add my:

Anyway as another improvement for future I would suggest some API function with _optional_ logic, so it could be used for more PCIe

I think we need to see how many are attaching reset lines to subnodes. If there are multiple then I agree we could add _optional. So far I see:

dtor@dtor-ws:~/kernel/linux-next (gpiod_get_from_of_node-remove)$ git grep '"reset"' -- drivers/pci/controller/
drivers/pci/controller/cadence/pci-j721e.c: gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
drivers/pci/controller/dwc/pci-keystone.c: gpiod = devm_gpiod_get_optional(dev, "reset",
drivers/pci/controller/dwc/pci-meson.c: mp->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);

drivers/pci/controller/dwc/pcie-dw-rockchip.c:  rockchip->rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
drivers/pci/controller/dwc/pcie-fu740.c:        afp->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
drivers/pci/controller/dwc/pcie-intel-gw.c:     pcie->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
drivers/pci/controller/dwc/pcie-keembay.c:      pcie->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
drivers/pci/controller/dwc/pcie-qcom-ep.c:      pcie_ep->reset = devm_gpiod_get(dev, "reset", GPIOD_IN);
drivers/pci/controller/dwc/pcie-tegra194.c:     pcie->pex_rst_gpiod = devm_gpiod_get(pcie->dev, "reset", GPIOD_IN);

drivers/pci/controller/pci-aardvark.c: pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
drivers/pci/controller/pci-tegra.c: "reset",
drivers/pci/controller/pcie-apple.c: "reset", 0, GPIOD_OUT_LOW, "PERST#");
drivers/pci/controller/pcie-mt7621.c: port->gpio_rst = devm_gpiod_get_index_optional(dev, "reset", slot,

So majority have reset lines attached to the "main" node and thus can use devm_gpiod_get_optional().

Thanks.

Signature · 1 line
Dmitry
Reviewed-by on v1 6/11
#32 lore raw

Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional()

In reply to Dmitry Torokhov
Quoted 10 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic device property API.

I believe that the only reason the driver, instead of the standard devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is because it wanted to set up a pretty consumer name for the GPIO, and we now have a special API for that.

Yours,
Linus Walleij

#33 lore raw

PATCH 7/11 PCI: apple: switch to using fwnode_gpiod_get_index()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

drivers/pci/controller/pcie-apple.c +2 -2
index a2c3c207a04b..d83817d3ff86 100644
@@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	u32 stat, idx;
 	int ret, i;
 
-	reset = gpiod_get_from_of_node(np, "reset-gpios", 0,
-				       GPIOD_OUT_LOW, "PERST#");
+	reset = fwnode_gpiod_get_index(of_fwnode_handle(np),
+				       "reset", 0, GPIOD_OUT_LOW, "PERST#");
 	if (IS_ERR(reset))
 		return PTR_ERR(reset);
 
Signature · 1 line
b4 0.10.0-dev-fc921
#34 lore raw

Re: [PATCH v1 07/11] PCI: apple: switch to using fwnode_gpiod_get_index()

Quoted 11 lines · Dmitry Torokhov

I would like to stop exporting OF-specific gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

drivers/pci/controller/pcie-apple.c +0 -0
index a2c3c207a04b..d83817d3ff86 100644

drivers/pci/controller/pcie-apple.c static int apple_pcie_setup_port(struct apple_pcie *pcie, · line 520

Quoted 7 lines
drivers/pci/controller/pcie-apple.c +2 -2
@@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	u32 stat, idx;
 	int ret, i;
 
-	reset = gpiod_get_from_of_node(np, "reset-gpios", 0,
-				       GPIOD_OUT_LOW, "PERST#");
+	reset = fwnode_gpiod_get_index(of_fwnode_handle(np),
+				       "reset", 0, GPIOD_OUT_LOW, "PERST#");

Hmm, I am looking at the driver and it leaks the reset gpio on unbind/unload. I guess it does not matter in practice, but still nice not to leak. Thankfully it is easy to cure by switching to devm option:
devm_fwnode_gpiod_get().

I'll send and updated patch with a new justification.

Thanks.

Signature · 1 line
Dmitry
Reviewed-by
#35 lore raw

Re: [PATCH v1 07/11] PCI: apple: switch to using fwnode_gpiod_get_index()

Quoted 25 lines · Dmitry Torokhov
Quoted 11 lines · Dmitry Torokhov

I would like to stop exporting OF-specific gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

drivers/pci/controller/pcie-apple.c +0 -0
index a2c3c207a04b..d83817d3ff86 100644

drivers/pci/controller/pcie-apple.c static int apple_pcie_setup_port(struct apple_pcie *pcie, · line 520

Quoted 7 lines
drivers/pci/controller/pcie-apple.c +2 -2
@@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
      u32 stat, idx;
      int ret, i;
 
-     reset = gpiod_get_from_of_node(np, "reset-gpios", 0,
-                                    GPIOD_OUT_LOW, "PERST#");
+     reset = fwnode_gpiod_get_index(of_fwnode_handle(np),
+                                    "reset", 0, GPIOD_OUT_LOW, "PERST#");

Hmm, I am looking at the driver and it leaks the reset gpio on unbind/unload. I guess it does not matter in practice, but still nice not to leak. Thankfully it is easy to cure by switching to devm option:
devm_fwnode_gpiod_get().

Quoted 1 line

I'll send and updated patch with a new justification.

With that change:

Yours,
Linus Walleij

#36 lore raw

PATCH 8/11 regulator: bd71815: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

drivers/regulator/bd71815-regulator.c +3 -4
index acaa6607898e..c2b8b8be7824 100644
@@ -571,11 +571,10 @@ static int bd7181x_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "No parent regmap\n");
 		return -ENODEV;
 	}
-	ldo4_en = devm_gpiod_get_from_of_node(&pdev->dev,
-					      pdev->dev.parent->of_node,
-						 "rohm,vsel-gpios", 0,
-						 GPIOD_ASIS, "ldo4-en");
 
+	ldo4_en = devm_fwnode_gpiod_get(&pdev->dev,
+					dev_fwnode(pdev->dev.parent),
+					"rohm,vsel", GPIOD_ASIS, "ldo4-en");
 	if (IS_ERR(ldo4_en)) {
 		ret = PTR_ERR(ldo4_en);
 		if (ret != -ENOENT)
Signature · 1 line
b4 0.10.0-dev-fc921
maintainer Reviewed-by on v1 8/11
#37 lore raw

Re: [PATCH v1 08/11] regulator: bd71815: switch to using devm_fwnode_gpiod_get()

Quoted 5 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

Quoted 21 lines
drivers/regulator/bd71815-regulator.c +3 -4
index acaa6607898e..c2b8b8be7824 100644
@@ -571,11 +571,10 @@ static int bd7181x_probe(struct platform_device *pdev)
  		dev_err(&pdev->dev, "No parent regmap\n");
  		return -ENODEV;
  	}
-	ldo4_en = devm_gpiod_get_from_of_node(&pdev->dev,
-					      pdev->dev.parent->of_node,
-						 "rohm,vsel-gpios", 0,
-						 GPIOD_ASIS, "ldo4-en");
 
+	ldo4_en = devm_fwnode_gpiod_get(&pdev->dev,
+					dev_fwnode(pdev->dev.parent),
+					"rohm,vsel", GPIOD_ASIS, "ldo4-en");
  	if (IS_ERR(ldo4_en)) {
  		ret = PTR_ERR(ldo4_en);
  		if (ret != -ENOENT)
Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
Reviewed-by on v1 8/11
#38 lore raw

Re: [PATCH v1 08/11] regulator: bd71815: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov
Quoted 4 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

Special thanks for using dev_fwnode().

(Dunno if my suggestion about parent applies here)

Quoted 24 lines
drivers/regulator/bd71815-regulator.c +3 -5
index acaa6607898e..c2b8b8be7824 100644
@@ -571,11 +571,10 @@ static int bd7181x_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "No parent regmap\n");
                return -ENODEV;
        }
-       ldo4_en = devm_gpiod_get_from_of_node(&pdev->dev,
-                                             pdev->dev.parent->of_node,
-                                                "rohm,vsel-gpios", 0,
-                                                GPIOD_ASIS, "ldo4-en");
 
+       ldo4_en = devm_fwnode_gpiod_get(&pdev->dev,
+                                       dev_fwnode(pdev->dev.parent),
+                                       "rohm,vsel", GPIOD_ASIS, "ldo4-en");
        if (IS_ERR(ldo4_en)) {
                ret = PTR_ERR(ldo4_en);
                if (ret != -ENOENT)
 
--

b4 0.10.0-dev-fc921

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#40 lore raw

PATCH 9/11 regulator: bd9576: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in bd957x_probe() to the generic device property API as well.

drivers/regulator/bd9576-regulator.c +9 -8
index aa42da4d141e..393c8693b327 100644
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>
@@ -939,8 +940,8 @@ static int bd957x_probe(struct platform_device *pdev)
 	}
 
 	ic_data->regmap = regmap;
-	vout_mode = of_property_read_bool(pdev->dev.parent->of_node,
-					 "rohm,vout1-en-low");
+	vout_mode = device_property_read_bool(pdev->dev.parent,
+					      "rohm,vout1-en-low");
 	if (vout_mode) {
 		struct gpio_desc *en;
 
@@ -948,10 +949,10 @@ static int bd957x_probe(struct platform_device *pdev)
 
 		/* VOUT1 enable state judged by VOUT1_EN pin */
 		/* See if we have GPIO defined */
-		en = devm_gpiod_get_from_of_node(&pdev->dev,
-						 pdev->dev.parent->of_node,
-						 "rohm,vout1-en-gpios", 0,
-						 GPIOD_OUT_LOW, "vout1-en");
+		en = devm_fwnode_gpiod_get(&pdev->dev,
+					   dev_fwnode(pdev->dev.parent),
+					   "rohm,vout1-en", GPIOD_OUT_LOW,
+					   "vout1-en");
 		if (!IS_ERR(en)) {
 			/* VOUT1_OPS gpio ctrl */
 			/*
@@ -986,8 +987,8 @@ static int bd957x_probe(struct platform_device *pdev)
 	 * like DDR voltage selection.
 	 */
 	platform_set_drvdata(pdev, ic_data);
-	ddr_sel =  of_property_read_bool(pdev->dev.parent->of_node,
-					 "rohm,ddr-sel-low");
+	ddr_sel = device_property_read_bool(pdev->dev.parent,
+					    "rohm,ddr-sel-low");
 	if (ddr_sel)
 		ic_data->regulator_data[2].desc.fixed_uV = 1350000;
 	else
Signature · 1 line
b4 0.10.0-dev-fc921
maintainer Reviewed-by on v1 9/11
#41 lore raw

Re: [PATCH v1 09/11] regulator: bd9576: switch to using devm_fwnode_gpiod_get()

Quoted 8 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in bd957x_probe() to the generic device property API as well.

Thanks!

Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
Reviewed-by on v1 9/11
#42 lore raw

Re: [PATCH v1 09/11] regulator: bd9576: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in bd957x_probe() to the generic device property API as well.

With or without below addressed,

Quoted 15 lines
drivers/regulator/bd9576-regulator.c +1 -0
index aa42da4d141e..393c8693b327 100644
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>

drivers/regulator/bd9576-regulator.c static int bd957x_probe(struct platform_device *pdev) · line 944

Quoted 7 lines
drivers/regulator/bd9576-regulator.c +2 -2
@@ -939,8 +940,8 @@ static int bd957x_probe(struct platform_device *pdev)
        }
 
        ic_data->regmap = regmap;
-       vout_mode = of_property_read_bool(pdev->dev.parent->of_node,
-                                        "rohm,vout1-en-low");
+       vout_mode = device_property_read_bool(pdev->dev.parent,
+                                             "rohm,vout1-en-low");

They all using parent device and you may make code neater by adding

  struct device *parent = pdev->dev.parent;

at the definition block of the probe function.

Quoted 32 lines
drivers/regulator/bd9576-regulator.c +6 -7
        if (vout_mode) {
                struct gpio_desc *en;
 
@@ -948,10 +949,10 @@ static int bd957x_probe(struct platform_device *pdev)
 
                /* VOUT1 enable state judged by VOUT1_EN pin */
                /* See if we have GPIO defined */
-               en = devm_gpiod_get_from_of_node(&pdev->dev,
-                                                pdev->dev.parent->of_node,
-                                                "rohm,vout1-en-gpios", 0,
-                                                GPIOD_OUT_LOW, "vout1-en");
+               en = devm_fwnode_gpiod_get(&pdev->dev,
+                                          dev_fwnode(pdev->dev.parent),
+                                          "rohm,vout1-en", GPIOD_OUT_LOW,
+                                          "vout1-en");
                if (!IS_ERR(en)) {
                        /* VOUT1_OPS gpio ctrl */
                        /*
@@ -986,8 +987,8 @@ static int bd957x_probe(struct platform_device *pdev)
         * like DDR voltage selection.
         */
        platform_set_drvdata(pdev, ic_data);
-       ddr_sel =  of_property_read_bool(pdev->dev.parent->of_node,
-                                        "rohm,ddr-sel-low");
+       ddr_sel = device_property_read_bool(pdev->dev.parent,
+                                           "rohm,ddr-sel-low");
        if (ddr_sel)
                ic_data->regulator_data[2].desc.fixed_uV = 1350000;
        else
 
--

b4 0.10.0-dev-fc921

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#43 lore raw

Re: [PATCH v1 09/11] regulator: bd9576: switch to using devm_fwnode_gpiod_get()

Quoted 38 lines · Andy Shevchenko
Quoted 7 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in bd957x_probe() to the generic device property API as well.

With or without below addressed,

Quoted 15 lines
drivers/regulator/bd9576-regulator.c +1 -0
index aa42da4d141e..393c8693b327 100644
@@ -12,6 +12,7 @@
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/platform_device.h>
+#include <linux/property.h>
  #include <linux/regulator/driver.h>
  #include <linux/regulator/machine.h>
  #include <linux/regulator/of_regulator.h>

drivers/regulator/bd9576-regulator.c static int bd957x_probe(struct platform_device *pdev) · line 944

Quoted 7 lines
drivers/regulator/bd9576-regulator.c +2 -2
@@ -939,8 +940,8 @@ static int bd957x_probe(struct platform_device *pdev)
         }
 
         ic_data->regmap = regmap;
-       vout_mode = of_property_read_bool(pdev->dev.parent->of_node,
-                                        "rohm,vout1-en-low");
+       vout_mode = device_property_read_bool(pdev->dev.parent,
+                                             "rohm,vout1-en-low");

They all using parent device and you may make code neater by adding

Quoted 1 line
   struct device *parent = pdev->dev.parent;

This is a matter of personal preference. I prefer seeing pdev->dev.parent - as it is more obvious (to me) what the 'pdev' is than what 'parent' would be.

I'd use the local variable only when it shortens at least one of the lines so that we avoid splitting it. After that being said - I'm not going to argue over this change either if one who is improving the driver wants to use the "helper" variable here.

Best Regards
-- Matti

Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
#44 lore raw

Re: [PATCH v1 09/11] regulator: bd9576: switch to using devm_fwnode_gpiod_get()

Quoted 3 lines · Matti Vaittinen
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:33 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 7 lines
Quoted 6 lines

drivers/regulator/bd9576-regulator.c static int bd957x_probe(struct platform_device *pdev) · line 944

Quoted 2 lines
drivers/regulator/bd9576-regulator.c +2 -0
+       vout_mode = device_property_read_bool(pdev->dev.parent,
+                                             "rohm,vout1-en-low");

They all using parent device and you may make code neater by adding

   struct device *parent = pdev->dev.parent;
Quoted 8 lines

This is a matter of personal preference. I prefer seeing pdev->dev.parent - as it is more obvious (to me) what the 'pdev' is than what 'parent' would be.

I'd use the local variable only when it shortens at least one of the lines so that we avoid splitting it. After that being said - I'm not going to argue over this change either if one who is improving the driver wants to use the "helper" variable here.

And I believe the quoted one is exactly the case of what you are saying above.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#45 lore raw

PATCH 10/11 watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in bd9576_wdt_probe() to the generic device property API as well.

drivers/watchdog/bd9576_wdt.c +31 -20
index 0b6999f3b6e8..4a20e07fbb69 100644
@@ -9,8 +9,8 @@
 #include <linux/gpio/consumer.h>
 #include <linux/mfd/rohm-bd957x.h>
 #include <linux/module.h>
-#include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/watchdog.h>
 
@@ -202,10 +202,10 @@ static int bd957x_set_wdt_mode(struct bd9576_wdt_priv *priv, int hw_margin,
 static int bd9576_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = dev->parent->of_node;
 	struct bd9576_wdt_priv *priv;
 	u32 hw_margin[2];
 	u32 hw_margin_max = BD957X_WDT_DEFAULT_MARGIN, hw_margin_min = 0;
+	int count;
 	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -221,40 +221,51 @@ static int bd9576_wdt_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	priv->gpiod_en = devm_gpiod_get_from_of_node(dev, dev->parent->of_node,
-						     "rohm,watchdog-enable-gpios",
-						     0, GPIOD_OUT_LOW,
-						     "watchdog-enable");
+	priv->gpiod_en = devm_fwnode_gpiod_get(dev, dev_fwnode(dev->parent),
+					       "rohm,watchdog-enable",
+					       GPIOD_OUT_LOW,
+					       "watchdog-enable");
 	if (IS_ERR(priv->gpiod_en))
 		return dev_err_probe(dev, PTR_ERR(priv->gpiod_en),
 			      "getting watchdog-enable GPIO failed\n");
 
-	priv->gpiod_ping = devm_gpiod_get_from_of_node(dev, dev->parent->of_node,
-						     "rohm,watchdog-ping-gpios",
-						     0, GPIOD_OUT_LOW,
-						     "watchdog-ping");
+	priv->gpiod_ping = devm_fwnode_gpiod_get(dev, dev_fwnode(dev->parent),
+						 "rohm,watchdog-ping",
+						 GPIOD_OUT_LOW,
+						 "watchdog-ping");
 	if (IS_ERR(priv->gpiod_ping))
 		return dev_err_probe(dev, PTR_ERR(priv->gpiod_ping),
 				     "getting watchdog-ping GPIO failed\n");
 
-	ret = of_property_read_variable_u32_array(np, "rohm,hw-timeout-ms",
-						  &hw_margin[0], 1, 2);
-	if (ret < 0 && ret != -EINVAL)
-		return ret;
+	count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms");
+	if (count < 0 && count != -EINVAL)
+		return count;
+
+	if (count > 0) {
+		if (count > ARRAY_SIZE(hw_margin))
+			return -EINVAL;
 
-	if (ret == 1)
-		hw_margin_max = hw_margin[0];
+		ret = device_property_read_u32_array(dev->parent,
+						     "rohm,hw-timeout-ms",
+						     hw_margin, count);
+		if (ret < 0)
+			return ret;
 
-	if (ret == 2) {
-		hw_margin_max = hw_margin[1];
-		hw_margin_min = hw_margin[0];
+		if (count == 1)
+			hw_margin_max = hw_margin[0];
+
+		if (count == 2) {
+			hw_margin_max = hw_margin[1];
+			hw_margin_min = hw_margin[0];
+		}
 	}
 
 	ret = bd957x_set_wdt_mode(priv, hw_margin_max, hw_margin_min);
 	if (ret)
 		return ret;
 
-	priv->always_running = of_property_read_bool(np, "always-running");
+	priv->always_running = device_property_read_bool(dev->parent,
+							 "always-running");
 
 	watchdog_set_drvdata(&priv->wdd, priv);
 
Signature · 1 line
b4 0.10.0-dev-fc921
#46 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

Quoted 6 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in

it, switch

Quoted 1 line

bd9576_wdt_probe() to the generic device property API as well.

...

Quoted 1 line
        struct device *dev = &pdev->dev;

struct device *parent = dev->parent;

can make your code slightly neater.

...

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev)

Quoted 8 lines
drivers/watchdog/bd9576_wdt.c +7 -0
+       count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms");
+       if (count < 0 && count != -EINVAL)
+               return count;
+
+       if (count > 0) {
 
+               if (count > ARRAY_SIZE(hw_margin))
+                       return -EINVAL;

Why double check? You may move it out of the (count > 0).

...

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev) · line 252

Quoted 8 lines
drivers/watchdog/bd9576_wdt.c +5 -2
-       if (ret == 1)
-               hw_margin_max = hw_margin[0];
 
+               ret = device_property_read_u32_array(dev->parent,
+                                                    "rohm,hw-timeout-ms",
+                                                    hw_margin, count);
+               if (ret < 0)
+                       return ret;

So, only this needs the count > 0 check since below already has it implicitly.

Quoted 11 lines
drivers/watchdog/bd9576_wdt.c +7 -3
-       if (ret == 2) {
-               hw_margin_max = hw_margin[1];
-               hw_margin_min = hw_margin[0];
+               if (count == 1)
+                       hw_margin_max = hw_margin[0];
+
+               if (count == 2) {
+                       hw_margin_max = hw_margin[1];
+                       hw_margin_min = hw_margin[0];
+               }
        }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#47 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

Quoted 29 lines · Andy Shevchenko
Quoted 6 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in

it, switch

Quoted 1 line

bd9576_wdt_probe() to the generic device property API as well.

...

Quoted 1 line
         struct device *dev = &pdev->dev;

struct device *parent = dev->parent;

can make your code slightly neater.

...

Quoted 5 lines
drivers/watchdog/bd9576_wdt.c +5 -0
+       count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms");
+       if (count < 0 && count != -EINVAL)
+               return count;
+
+       if (count > 0) {
Quoted 5 lines

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev) · line 246

Quoted 2 lines
drivers/watchdog/bd9576_wdt.c +2 -0
+               if (count > ARRAY_SIZE(hw_margin))
+                       return -EINVAL;

Why double check? You may move it out of the (count > 0).

Two checks will always be needed, so I don't entirely see how that would be better.

Quoted 5 lines

...

Quoted 2 lines
drivers/watchdog/bd9576_wdt.c +0 -2
-       if (ret == 1)
-               hw_margin_max = hw_margin[0];
Quoted 8 lines

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev) · line 252

Quoted 5 lines
drivers/watchdog/bd9576_wdt.c +5 -0
+               ret = device_property_read_u32_array(dev->parent,
+                                                    "rohm,hw-timeout-ms",
+                                                    hw_margin, count);
+               if (ret < 0)
+                       return ret;

So, only this needs the count > 0 check since below already has it implicitly.

Sorry, I don't understand this comment.

Guenter

Quoted 12 lines
Quoted 11 lines
drivers/watchdog/bd9576_wdt.c +7 -3
-       if (ret == 2) {
-               hw_margin_max = hw_margin[1];
-               hw_margin_min = hw_margin[0];
+               if (count == 1)
+                       hw_margin_max = hw_margin[0];
+
+               if (count == 2) {
+                       hw_margin_max = hw_margin[1];
+                       hw_margin_min = hw_margin[0];
+               }
         }
#48 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

Quoted 3 lines · Guenter Roeck
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:33 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/watchdog/bd9576_wdt.c +5 -0
+       count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms");
+       if (count < 0 && count != -EINVAL)
+               return count;
+
+       if (count > 0) {
Quoted 7 lines
Quoted 4 lines

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev) · line 246

Quoted 2 lines
drivers/watchdog/bd9576_wdt.c +2 -0
+               if (count > ARRAY_SIZE(hw_margin))
+                       return -EINVAL;

Why double check? You may move it out of the (count > 0).

Two checks will always be needed, so I don't entirely see how that would be better.

But not nested. That's my point:

if (count > ARRAY_SIZE())
return ...
if (count > 0)
...

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/watchdog/bd9576_wdt.c +5 -2
-       if (ret == 1)
-               hw_margin_max = hw_margin[0];
 
+               ret = device_property_read_u32_array(dev->parent,
+                                                    "rohm,hw-timeout-ms",
+                                                    hw_margin, count);
+               if (ret < 0)
+                       return ret;
Quoted 3 lines
Quoted 2 lines

So, only this needs the count > 0 check since below already has it implicitly.

Sorry, I don't understand this comment.

if (count > 0) {
ret = device_property_read_u32_array(...);
...
}
if (count == 1)
...
if (count == 2)
...

But here it might be better to have the nested conditionals.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/watchdog/bd9576_wdt.c +7 -3
-       if (ret == 2) {
-               hw_margin_max = hw_margin[1];
-               hw_margin_min = hw_margin[0];
+               if (count == 1)
+                       hw_margin_max = hw_margin[0];
+
+               if (count == 2) {
+                       hw_margin_max = hw_margin[1];
+                       hw_margin_min = hw_margin[0];
+               }
         }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#49 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

Quoted 21 lines · Andy Shevchenko
Quoted 3 lines · Guenter Roeck
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:33 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/watchdog/bd9576_wdt.c +5 -0
+       count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms");
+       if (count < 0 && count != -EINVAL)
+               return count;
+
+       if (count > 0) {
Quoted 7 lines
Quoted 4 lines

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev) · line 246

Quoted 2 lines
drivers/watchdog/bd9576_wdt.c +2 -0
+               if (count > ARRAY_SIZE(hw_margin))
+                       return -EINVAL;

Why double check? You may move it out of the (count > 0).

Two checks will always be needed, so I don't entirely see how that would be better.

Quoted 7 lines

But not nested. That's my point:

if (count > ARRAY_SIZE())
return ...
if (count > 0)
...

The old code has either 1 or two checks if there is no error. Your suggested code has always two checks. I don't see how that is an improvement.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/watchdog/bd9576_wdt.c +5 -2
-       if (ret == 1)
-               hw_margin_max = hw_margin[0];
 
+               ret = device_property_read_u32_array(dev->parent,
+                                                    "rohm,hw-timeout-ms",
+                                                    hw_margin, count);
+               if (ret < 0)
+                       return ret;
Quoted 3 lines
Quoted 2 lines

So, only this needs the count > 0 check since below already has it implicitly.

Sorry, I don't understand this comment.

if (count > 0) {
   ret = device_property_read_u32_array(...);
   ...
}
Quoted 7 lines

if (count == 1)
...
if (count == 2)
...

But here it might be better to have the nested conditionals.

We know that count is either 1 or 2 here, so strictly speaking

	if (count == 1) {
	} else {
	}
would be sufficient. On the other side, that depends on ARRAY_SIZE() being
exactly 2, so
	if (count == 1) {
	} else if (count == 2) {
	}

would also make sense. Either way is fine with me. I'll leave it up to Dmitry to decide what he wants to do.

Thanks,
Guenter

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/watchdog/bd9576_wdt.c +7 -3
-       if (ret == 2) {
-               hw_margin_max = hw_margin[1];
-               hw_margin_min = hw_margin[0];
+               if (count == 1)
+                       hw_margin_max = hw_margin[0];
+
+               if (count == 2) {
+                       hw_margin_max = hw_margin[1];
+                       hw_margin_min = hw_margin[0];
+               }
          }
#50 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

Quoted 68 lines · Guenter Roeck
Quoted 21 lines · Andy Shevchenko
Quoted 3 lines · Guenter Roeck
Quoted 2 lines · Andy Shevchenko

On Mon, Sep 5, 2022 at 9:33 AM Dmitry Torokhov
<[email protected]> wrote:

...

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/watchdog/bd9576_wdt.c +5 -0
+       count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms");
+       if (count < 0 && count != -EINVAL)
+               return count;
+
+       if (count > 0) {
Quoted 7 lines
Quoted 4 lines

drivers/watchdog/bd9576_wdt.c static int bd9576_wdt_probe(struct platform_device *pdev) · line 246

Quoted 2 lines
drivers/watchdog/bd9576_wdt.c +2 -0
+               if (count > ARRAY_SIZE(hw_margin))
+                       return -EINVAL;

Why double check? You may move it out of the (count > 0).

Two checks will always be needed, so I don't entirely see how that would be better.

Quoted 7 lines

But not nested. That's my point:

if (count > ARRAY_SIZE())
return ...
if (count > 0)
...

The old code has either 1 or two checks if there is no error. Your suggested code has always two checks. I don't see how that is an improvement.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/watchdog/bd9576_wdt.c +5 -2
-       if (ret == 1)
-               hw_margin_max = hw_margin[0];
 
+               ret = device_property_read_u32_array(dev->parent,
+                                                    "rohm,hw-timeout-ms",
+                                                    hw_margin, count);
+               if (ret < 0)
+                       return ret;
Quoted 3 lines
Quoted 2 lines

So, only this needs the count > 0 check since below already has it implicitly.

Sorry, I don't understand this comment.

if (count > 0) {
   ret = device_property_read_u32_array(...);
   ...
}
Quoted 7 lines

if (count == 1)
...
if (count == 2)
...

But here it might be better to have the nested conditionals.

We know that count is either 1 or 2 here, so strictly speaking

	if (count == 1) {
	} else {
	}
would be sufficient. On the other side, that depends on ARRAY_SIZE() being
exactly 2, so
	if (count == 1) {
	} else if (count == 2) {
	}
Quoted 2 lines

would also make sense. Either way is fine with me. I'll leave it up to Dmitry to decide what he wants to do.

My goal is to drop usage of devm_gpiod_get_from_of_node(), beyond that I do not have strong preferences either way really. It is probing code, so performance is not critical, but I'm obviously satisfied with how the code looks now, or I would not have sent it.

Thanks.

Signature · 1 line
Dmitry
maintainer Reviewed-by
#51 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

On 9/5/22 12:47, Dmitry Torokhov wrote:
[ ... ]

Quoted 12 lines
Quoted 11 lines

We know that count is either 1 or 2 here, so strictly speaking

	if (count == 1) {
	} else {
	}
would be sufficient. On the other side, that depends on ARRAY_SIZE() being
exactly 2, so
	if (count == 1) {
	} else if (count == 2) {
	}

would also make sense. Either way is fine with me. I'll leave it up to Dmitry to decide what he wants to do.

Quoted 5 lines

My goal is to drop usage of devm_gpiod_get_from_of_node(), beyond that I do not have strong preferences either way really. It is probing code, so performance is not critical, but I'm obviously satisfied with how the code looks now, or I would not have sent it.

Good point.

#52 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

Quoted 20 lines · Guenter Roeck

On 9/5/22 12:47, Dmitry Torokhov wrote:
[ ... ]

Quoted 12 lines
Quoted 11 lines

We know that count is either 1 or 2 here, so strictly speaking

	if (count == 1) {
	} else {
	}
would be sufficient. On the other side, that depends on ARRAY_SIZE() being
exactly 2, so
	if (count == 1) {
	} else if (count == 2) {
	}

would also make sense. Either way is fine with me. I'll leave it up to Dmitry to decide what he wants to do.

Quoted 5 lines

My goal is to drop usage of devm_gpiod_get_from_of_node(), beyond that I do not have strong preferences either way really. It is probing code, so performance is not critical, but I'm obviously satisfied with how the code looks now, or I would not have sent it.

Quoted 3 lines

Good point.

Guenter, individual patches are going through maintainer's trees, will you take this one?

Thanks.

Signature · 1 line
Dmitry
Reviewed-by on v1 10/11
#53 lore raw

Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov
Quoted 8 lines · Dmitry Torokhov

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() so that gpiolib can be cleaned a bit, so let's switch to the generic fwnode property API.

While at it switch the rest of the calls to read properties in bd9576_wdt_probe() to the generic device property API as well.

Yours,
Linus Walleij

#54 lore raw

PATCH 11/11 gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs

In reply to Dmitry Torokhov

Now that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, we no longer need to expose OF-specific [devm_]gpiod_get_from_of_node().

Note that we are keeping gpiod_get_from_of_node() but only as a private to gpiolib function.

drivers/gpio/gpiolib-devres.c +0 -55
index 16a696249229..fe9ce6b19f15 100644
@@ -129,61 +129,6 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_gpiod_get_index);
 
-/**
- * devm_gpiod_get_from_of_node() - obtain a GPIO from an OF node
- * @dev:	device for lifecycle management
- * @node:	handle of the OF node
- * @propname:	name of the DT property representing the GPIO
- * @index:	index of the GPIO to obtain for the consumer
- * @dflags:	GPIO initialization flags
- * @label:	label to attach to the requested GPIO
- *
- * Returns:
- * On successful request the GPIO pin is configured in accordance with
- * provided @dflags.
- *
- * In case of error an ERR_PTR() is returned.
- */
-struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
-					      const struct device_node *node,
-					      const char *propname, int index,
-					      enum gpiod_flags dflags,
-					      const char *label)
-{
-	struct gpio_desc **dr;
-	struct gpio_desc *desc;
-
-	desc = gpiod_get_from_of_node(node, propname, index, dflags, label);
-	if (IS_ERR(desc))
-		return desc;
-
-	/*
-	 * For non-exclusive GPIO descriptors, check if this descriptor is
-	 * already under resource management by this device.
-	 */
-	if (dflags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
-		struct devres *dres;
-
-		dres = devres_find(dev, devm_gpiod_release,
-				   devm_gpiod_match, &desc);
-		if (dres)
-			return desc;
-	}
-
-	dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *),
-			  GFP_KERNEL);
-	if (!dr) {
-		gpiod_put(desc);
-		return ERR_PTR(-ENOMEM);
-	}
-
-	*dr = desc;
-	devres_add(dev, dr);
-
-	return desc;
-}
-EXPORT_SYMBOL_GPL(devm_gpiod_get_from_of_node);
-
 /**
  * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node
  * @dev:	GPIO consumer
drivers/gpio/gpiolib-of.c +0 -1
index a037b50bef33..b0e0723b12ab 100644
@@ -365,7 +365,6 @@ struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
 
 	return desc;
 }
-EXPORT_SYMBOL_GPL(gpiod_get_from_of_node);
 
 /*
  * The SPI GPIO bindings happened before we managed to establish that GPIO
drivers/gpio/gpiolib-of.h +13 -0
index 8af2bc899aab..e0da568d6da3 100644
@@ -3,6 +3,7 @@
 #ifndef GPIOLIB_OF_H
 #define GPIOLIB_OF_H
 
+struct device_node;
 struct gpio_chip;
 enum of_gpio_flags;
 
@@ -16,6 +17,10 @@ void of_gpiochip_remove(struct gpio_chip *gc);
 int of_gpio_get_count(struct device *dev, const char *con_id);
 bool of_gpio_need_valid_mask(const struct gpio_chip *gc);
 void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
+struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
+					 const char *propname, int index,
+					 enum gpiod_flags dflags,
+					 const char *label);
 #else
 static inline struct gpio_desc *of_find_gpio(struct device *dev,
 					     const char *con_id,
@@ -38,6 +43,14 @@ static inline void of_gpio_dev_init(struct gpio_chip *gc,
 				    struct gpio_device *gdev)
 {
 }
+static inline
+struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
+					 const char *propname, int index,
+					 enum gpiod_flags dflags,
+					 const char *label)
+{
+	return ERR_PTR(-ENOSYS);
+}
 #endif /* CONFIG_OF_GPIO */
 
 extern struct notifier_block gpio_of_notifier;
include/linux/gpio/consumer.h +0 -48

54 lines not on this page · raw message

Signature · 1 line
b4 0.10.0-dev-fc921
Reviewed-by on v1 11/11
#55 lore raw

Re: [PATCH v1 11/11] gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs

Quoted 7 lines · Dmitry Torokhov

Now that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, we no longer need to expose OF-specific [devm_]gpiod_get_from_of_node().

Note that we are keeping gpiod_get_from_of_node() but only as a private to gpiolib function.

Yours,
Linus Walleij

#56 lore raw
In reply to Dmitry Torokhov
Quoted 10 lines · Dmitry Torokhov

I would like to stop exporting OF-specific [devm_]gpiod_get_from_of_node() so that gpiolib can be cleaned a bit. We can do that by switching drivers to use generic fwnode API ([devm_]fwnode_gpiod_get()). By doing so we open the door to augmenting device tree and ACPI information through secondary software properties (once we teach gpiolib how to handle those).

I hope that relevant maintainers will take patches through their trees and then we could merge the last one some time after -rc1.

Nice work, I'll go add the USB ones to my tree now, thanks!

greg k-h

#57 lore raw
In reply to Dmitry Torokhov
Quoted 9 lines · Dmitry Torokhov

I would like to stop exporting OF-specific [devm_]gpiod_get_from_of_node() so that gpiolib can be cleaned a bit. We can do that by switching drivers to use generic fwnode API ([devm_]fwnode_gpiod_get()). By doing so we open the door to augmenting device tree and ACPI information through secondary software properties (once we teach gpiolib how to handle those).

I hope that relevant maintainers will take patches through their trees and then we could merge the last one some time after -rc1.

I'm in favour of the series, but some comments would be good to be addressed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#58 lore raw

Re: (subset) [PATCH v1 00/11] Get rid of [devm_]gpiod_get_from_of_node() public APIs

In reply to Dmitry Torokhov
Quoted 10 lines · Dmitry Torokhov

I would like to stop exporting OF-specific [devm_]gpiod_get_from_of_node() so that gpiolib can be cleaned a bit. We can do that by switching drivers to use generic fwnode API ([devm_]fwnode_gpiod_get()). By doing so we open the door to augmenting device tree and ACPI information through secondary software properties (once we teach gpiolib how to handle those).

I hope that relevant maintainers will take patches through their trees and then we could merge the last one some time after -rc1.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[08/11] regulator: bd71815: switch to using devm_fwnode_gpiod_get()

        commit: 97c9278ec624a0d5d7c56aa20e16afc8aaa96557
[09/11] regulator: bd9576: switch to using devm_fwnode_gpiod_get()
        commit: 587bfe3f7a270f0a4076e624d318292324bdead8

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

maintainer Applied
#59 lore raw

Re: (subset) [PATCH v1 00/11] Get rid of [devm_]gpiod_get_from_of_node() public APIs

In reply to Dmitry Torokhov
Quoted 10 lines · Dmitry Torokhov

I would like to stop exporting OF-specific [devm_]gpiod_get_from_of_node() so that gpiolib can be cleaned a bit. We can do that by switching drivers to use generic fwnode API ([devm_]fwnode_gpiod_get()). By doing so we open the door to augmenting device tree and ACPI information through secondary software properties (once we teach gpiolib how to handle those).

I hope that relevant maintainers will take patches through their trees and then we could merge the last one some time after -rc1.

[...]

Applied to pci/tegra, thanks!

[01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

        https://git.kernel.org/lpieralisi/pci/c/16e3f4077965

Thanks,
Lorenzo

#60 lore raw

Re: (subset) [PATCH v1 00/11] Get rid of [devm_]gpiod_get_from_of_node() public APIs

Hi Lorenzo,

Quoted 10 lines · Lorenzo Pieralisi
Quoted 9 lines · Dmitry Torokhov

I would like to stop exporting OF-specific [devm_]gpiod_get_from_of_node() so that gpiolib can be cleaned a bit. We can do that by switching drivers to use generic fwnode API ([devm_]fwnode_gpiod_get()). By doing so we open the door to augmenting device tree and ACPI information through secondary software properties (once we teach gpiolib how to handle those).

I hope that relevant maintainers will take patches through their trees and then we could merge the last one some time after -rc1.

Quoted 6 lines
Quoted 1 line

[...]

Applied to pci/tegra, thanks!

[01/11] PCI: tegra: switch to using devm_fwnode_gpiod_get

        https://git.kernel.org/lpieralisi/pci/c/16e3f4077965

Any chance you could also pick up

[06/11] PCI: aardvark: switch to using devm_gpiod_get_optional() (20220903-gpiod_get_from_of_node-remove-v1-6-b29adfb27a6c@gmail.com)

- Pali Rohár has acked it.

Thanks!

Signature · 1 line
Dmitry