Skip to contentSkip to conversation

PCI: aardvark: switch to using devm_gpiod_get_optional()

PATCH In review Dmitry Torokhov 3 participants 9 messages Nov 14, 2022 – Dec 16, 2022

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

PATCH v2 1/1 PCI: aardvark: switch to using devm_gpiod_get_optional()

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

---

v2:
- collected reviewed-by/acked-by tags
- updated commit description to remove incorrect assumption of why devm_gpiod_get_from_of_node() was used in the first place

This is the last user of devm_gpiod_get_from_of_node() in the mainline (next), it would be great to have it in so that we can remove the API in the next release cycle.

Thanks!

 drivers/pci/controller/pci-aardvark.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/pci/controller/pci-aardvark.c +11 -12
index ba36bbc5897d..5ecfac23c9fc 100644
@@ -1859,20 +1859,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 · 5 lines
2.38.1.431.g37b22c650d-goog


-- 
Dmitry
maintainer
#1 lore raw
Quoted 14 lines · On Monday 14 November 2022 10:42:25 Dmitry Torokhov wrote:

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

---

v2:
- collected reviewed-by/acked-by tags
- updated commit description to remove incorrect assumption of why devm_gpiod_get_from_of_node() was used in the first place

Quoted 5 lines

This is the last user of devm_gpiod_get_from_of_node() in the mainline (next), it would be great to have it in so that we can remove the API in the next release cycle.

Thanks!

Just a note that more aardvark patches are waiting on the list.

Quoted 46 lines
 drivers/pci/controller/pci-aardvark.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/pci/controller/pci-aardvark.c +11 -12
index ba36bbc5897d..5ecfac23c9fc 100644
@@ -1859,20 +1859,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 · 5 lines
2.38.1.431.g37b22c650d-goog


-- 
Dmitry
#2 lore raw
In reply to Dmitry Torokhov
Quoted 14 lines · Dmitry Torokhov

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

---

v2:
- collected reviewed-by/acked-by tags
- updated commit description to remove incorrect assumption of why devm_gpiod_get_from_of_node() was used in the first place

Quoted 5 lines

This is the last user of devm_gpiod_get_from_of_node() in the mainline (next), it would be great to have it in so that we can remove the API in the next release cycle.

Thanks!

Gentle ping on this one... I'd really like to remove [devm_]gpiod_get_from_of_node() API from 6.2.

Thanks.

Signature · 1 line
Dmitry
maintainer
#3 lore raw
Quoted 19 lines · On Tuesday 06 December 2022 17:31:11 Dmitry Torokhov wrote:
Quoted 18 lines · Dmitry Torokhov

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

---

v2:
- collected reviewed-by/acked-by tags
- updated commit description to remove incorrect assumption of why devm_gpiod_get_from_of_node() was used in the first place

This is the last user of devm_gpiod_get_from_of_node() in the mainline (next), it would be great to have it in so that we can remove the API in the next release cycle.

Quoted 9 lines
Quoted 1 line

Thanks!

Gentle ping on this one... I'd really like to remove [devm_]gpiod_get_from_of_node() API from 6.2.

Thanks.

Signature · 1 line
Dmitry

Hello Dmitry! You would need to wait with your change. There are more important fixes and less important cleanups for this aardvark driver which are waiting in the queue for longer time:
https://patchwork.kernel.org/project/linux-pci/list/?series=&submitter=&state=&q=aardvark&archive=&delegate=

#4 lore raw
In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

This is unrelated to other pending aardvark changes and will help unblock the API removal, so I applied this to pci/ctrl/aardvark for v6.2, thanks!

Quoted 64 lines

---

v2:
- collected reviewed-by/acked-by tags
- updated commit description to remove incorrect assumption of why devm_gpiod_get_from_of_node() was used in the first place

This is the last user of devm_gpiod_get_from_of_node() in the mainline (next), it would be great to have it in so that we can remove the API in the next release cycle.

Thanks!

 drivers/pci/controller/pci-aardvark.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/pci/controller/pci-aardvark.c +11 -12
index ba36bbc5897d..5ecfac23c9fc 100644
@@ -1859,20 +1859,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 · 10 lines
2.38.1.431.g37b22c650d-goog


-- 
Dmitry

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#5 lore raw
Quoted 5 lines · Bjorn Helgaas
Quoted 4 lines · Dmitry Torokhov

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

Quoted 7 lines
Quoted 3 lines

This is unrelated to other pending aardvark changes and will help unblock the API removal, so I applied this to pci/ctrl/aardvark for v6.2, thanks!

Thank you Bjorn!

I wonder if you could also consider picking up the mvebu patch:

https://lore.kernel.org/all/[email protected]/

pci-mvebu.c is the very last user of of_get_named_gpio_flags() in the next tree, which we also want to stop exporting.

Thanks.

Signature · 1 line
Dmitry
#7 lore raw
Quoted 6 lines · Bjorn Helgaas
Quoted 5 lines · Dmitry Torokhov

...
I wonder if you could also consider picking up the mvebu patch:

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 2 lines

pci-mvebu.c is the very last user of of_get_named_gpio_flags() in the next tree, which we also want to stop exporting.

Sure, but the 0-day bot found a couple issues, which I haven't bothered to look into:

https://lore.kernel.org/all/[email protected]/

Ugh, indeed, I asumed this was an existing issue and of course I was wrong. linux/irqchip/chained_irq.h was previously included indirectly via linux/of_gpio.h and linux/gpio/driver.h.

I sent out v3 tha compiles cleanly.

Thanks.

Signature · 1 line
Dmitry
maintainer
#8 lore raw
In reply to Bjorn Helgaas
Quoted 5 lines · On Wednesday 07 December 2022 08:33:51 Bjorn Helgaas wrote:
Quoted 4 lines · Dmitry Torokhov

Switch the driver to the generic version of gpiod API (and away from OF-specific variant), so that we can stop exporting devm_gpiod_get_from_of_node().

Quoted 7 lines
Quoted 3 lines

This is unrelated to other pending aardvark changes and will help unblock the API removal, so I applied this to pci/ctrl/aardvark for v6.2, thanks!

I'm disappointed that such unimportant change is prioritized and taken before any other important changes which are fixing real issue and waiting for applying about half of year.

Quoted 64 lines
Quoted 64 lines

---

v2:
- collected reviewed-by/acked-by tags
- updated commit description to remove incorrect assumption of why devm_gpiod_get_from_of_node() was used in the first place

This is the last user of devm_gpiod_get_from_of_node() in the mainline (next), it would be great to have it in so that we can remove the API in the next release cycle.

Thanks!

 drivers/pci/controller/pci-aardvark.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/pci/controller/pci-aardvark.c +11 -12
index ba36bbc5897d..5ecfac23c9fc 100644
@@ -1859,20 +1859,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 · 10 lines
2.38.1.431.g37b22c650d-goog


-- 
Dmitry

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel