Skip to contentSkip to conversation

PCI: tegra194: use dev_err_probe() for PERST GPIO

PATCH Superseded [email protected] 4 participants 10 messages Oct 7 – Oct 12

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 PCI: tegra194: use dev_err_probe() for PERST GPIO

From: bui duc phuc <[email protected]>

Use dev_err_probe() when getting the PERST GPIO to simplify error handling and properly handle -EPROBE_DEFER.

---
 drivers/pci/controller/dwc/pcie-tegra194.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +3 -12
index 63a0f56cad8e..767e11216196 100644
@@ -1200,18 +1200,9 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
 
 	/* Endpoint mode specific DT entries */
 	pcie->pex_rst_gpiod = devm_gpiod_get(pcie->dev, "reset", GPIOD_IN);
-	if (IS_ERR(pcie->pex_rst_gpiod)) {
-		int err = PTR_ERR(pcie->pex_rst_gpiod);
-		const char *level = KERN_ERR;
-
-		if (err == -EPROBE_DEFER)
-			level = KERN_DEBUG;
-
-		dev_printk(level, pcie->dev,
-			   dev_fmt("Failed to get PERST GPIO: %d\n"),
-			   err);
-		return err;
-	}
+	if (IS_ERR(pcie->pex_rst_gpiod))
+		return dev_err_probe(pcie->dev, PTR_ERR(pcie->pex_rst_gpiod),
+				     "Failed to get PERST GPIO\n");
 
 	pcie->pex_refclk_sel_gpiod = devm_gpiod_get_optional(pcie->dev,
 							     "nvidia,refclk-select",
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 PCI: tegra194: propagate REFCLK select GPIO errors

From: bui duc phuc <[email protected]>

devm_gpiod_get_optional() returns NULL when the optional GPIO is not present, but may return -EPROBE_DEFER or other errors.

The current code treats GPIO lookup errors as if the GPIO were not present.

Check the return value and propagate errors from the REFCLK select GPIO lookup.

---
 drivers/pci/controller/dwc/pcie-tegra194.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +3 -12
index 767e11216196..5ebe01f72833 100644
@@ -1207,18 +1207,9 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
 	pcie->pex_refclk_sel_gpiod = devm_gpiod_get_optional(pcie->dev,
 							     "nvidia,refclk-select",
 							     GPIOD_OUT_HIGH);
-	if (IS_ERR(pcie->pex_refclk_sel_gpiod)) {
-		int err = PTR_ERR(pcie->pex_refclk_sel_gpiod);
-		const char *level = KERN_ERR;
-
-		if (err == -EPROBE_DEFER)
-			level = KERN_DEBUG;
-
-		dev_printk(level, pcie->dev,
-			   dev_fmt("Failed to get REFCLK select GPIOs: %d\n"),
-			   err);
-		pcie->pex_refclk_sel_gpiod = NULL;
-	}
+	if (IS_ERR(pcie->pex_refclk_sel_gpiod))
+		return dev_err_probe(pcie->dev, PTR_ERR(pcie->pex_refclk_sel_gpiod),
+				     "Failed to get REFCLK select GPIOs\n");
 
 	return 0;
 }
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 2/2] PCI: tegra194: propagate REFCLK select GPIO errors

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

From: bui duc phuc <[email protected]>

devm_gpiod_get_optional() returns NULL when the optional GPIO is not present, but may return -EPROBE_DEFER or other errors.

Quoted 7 lines

The current code treats GPIO lookup errors as if the GPIO were not present.

Check the return value and propagate errors from the REFCLK select GPIO lookup.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] PCI: tegra194: propagate REFCLK select GPIO errors

In reply to [email protected]
Quoted 11 lines · On 07/10/26 4:18 pm, [email protected] wrote:

From: bui duc phuc <[email protected]>

devm_gpiod_get_optional() returns NULL when the optional GPIO is not present, but may return -EPROBE_DEFER or other errors.

The current code treats GPIO lookup errors as if the GPIO were not present.

Check the return value and propagate errors from the REFCLK select GPIO lookup.

I published similar patch https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/

I am OK if this patch is merged, I will drop from my series.

With the subject line capitalization style fix,

Quoted 31 lines
---
  drivers/pci/controller/dwc/pcie-tegra194.c | 15 +++------------
  1 file changed, 3 insertions(+), 12 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +3 -12
index 767e11216196..5ebe01f72833 100644
@@ -1207,18 +1207,9 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
  	pcie->pex_refclk_sel_gpiod = devm_gpiod_get_optional(pcie->dev,
  							     "nvidia,refclk-select",
  							     GPIOD_OUT_HIGH);
-	if (IS_ERR(pcie->pex_refclk_sel_gpiod)) {
-		int err = PTR_ERR(pcie->pex_refclk_sel_gpiod);
-		const char *level = KERN_ERR;
-
-		if (err == -EPROBE_DEFER)
-			level = KERN_DEBUG;
-
-		dev_printk(level, pcie->dev,
-			   dev_fmt("Failed to get REFCLK select GPIOs: %d\n"),
-			   err);
-		pcie->pex_refclk_sel_gpiod = NULL;
-	}
+	if (IS_ERR(pcie->pex_refclk_sel_gpiod))
+		return dev_err_probe(pcie->dev, PTR_ERR(pcie->pex_refclk_sel_gpiod),
+				     "Failed to get REFCLK select GPIOs\n");
 
  	return 0;
  }
Signature · 1 line
nvpublic
#4 lore raw

Re: [PATCH 2/2] PCI: tegra194: propagate REFCLK select GPIO errors

Hi Manikanta,

Thanks for pointing this out. I wasn't aware that you had already posted a similar patch.

Quoted 8 lines

I published similar patch
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/

I am OK if this patch is merged, I will drop from my series.

With the subject line capitalization style fix,

I'll update the subject line capitalization and send v2 shortly. Thanks for the review.

Best regards,
Phuc

#5 lore raw
In reply to [email protected]
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines

From: bui duc phuc <[email protected]>

Use dev_err_probe() when getting the PERST GPIO to simplify error handling and properly handle -EPROBE_DEFER.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#6 lore raw
In reply to [email protected]
Quoted 6 lines · On Wed, Oct 07, 2026 at 05:48:46PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

Use dev_err_probe() when getting the PERST GPIO to simplify error handling and properly handle -EPROBE_DEFER.

For future posts, please match the subject line capitalization style:

PCI: tegra194: Use ...

And style as "PERST#" in the subject, commit log, and dmesg text to match spec usage.

No need to repost just for this; we can tweak these when applying.

Quoted 33 lines
---
 drivers/pci/controller/dwc/pcie-tegra194.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +3 -12
index 63a0f56cad8e..767e11216196 100644
@@ -1200,18 +1200,9 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
 
 	/* Endpoint mode specific DT entries */
 	pcie->pex_rst_gpiod = devm_gpiod_get(pcie->dev, "reset", GPIOD_IN);
-	if (IS_ERR(pcie->pex_rst_gpiod)) {
-		int err = PTR_ERR(pcie->pex_rst_gpiod);
-		const char *level = KERN_ERR;
-
-		if (err == -EPROBE_DEFER)
-			level = KERN_DEBUG;
-
-		dev_printk(level, pcie->dev,
-			   dev_fmt("Failed to get PERST GPIO: %d\n"),
-			   err);
-		return err;
-	}
+	if (IS_ERR(pcie->pex_rst_gpiod))
+		return dev_err_probe(pcie->dev, PTR_ERR(pcie->pex_rst_gpiod),
+				     "Failed to get PERST GPIO\n");
 
 	pcie->pex_refclk_sel_gpiod = devm_gpiod_get_optional(pcie->dev,
 							     "nvidia,refclk-select",
Signature · 1 line
2.43.0
#7 lore raw

Hi Bjorn,

Quoted 10 lines

For future posts, please match the subject line capitalization style:

PCI: tegra194: Use ...

And style as "PERST#" in the subject, commit log, and dmesg text to match spec usage.

No need to repost just for this; we can tweak these when applying.

Thanks for the review and for pointing this out. I'll keep these style details in mind for future posts.

Best regards,
Phuc

#8 lore raw
Quoted 10 lines · Bui Duc Phuc

Hi Bjorn,

Quoted 8 lines

For future posts, please match the subject line capitalization style:

   PCI: tegra194: Use ...

And style as "PERST#" in the subject, commit log, and dmesg text to match spec usage.

Quoted 8 lines
Quoted 2 lines

No need to repost just for this; we can tweak these when applying.

Thanks for the review and for pointing this out. I'll keep these style details in mind for future posts.

Best regards,
Phuc

With the subject line capitalization and "PERST#" style fixes,

Signature · 1 line
nvpublic