Skip to contentSkip to conversation

PCI: tegra: Fix reporting GPIO error value

PATCH Applied Pali Rohár 5 participants 7 messages Apr 14, 2020 – May 11, 2020

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

PATCH 1/1 PCI: tegra: Fix reporting GPIO error value

Error code is stored in rp->reset_gpio and not in err variable.

---
 drivers/pci/controller/pci-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-tegra.c +2 -2
index 0e03cef72840..378d5a8773c7 100644
@@ -2314,8 +2314,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 			if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
 				rp->reset_gpio = NULL;
 			} else {
-				dev_err(dev, "failed to get reset GPIO: %d\n",
-					err);
+				dev_err(dev, "failed to get reset GPIO: %ld\n",
+					PTR_ERR(rp->reset_gpio));
 				return PTR_ERR(rp->reset_gpio);
 			}
 		}
Signature · 1 line
2.20.1
#1 lore raw
Quoted 12 lines · Pali Rohár

Error code is stored in rp->reset_gpio and not in err variable.

---
 drivers/pci/controller/pci-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-tegra.c +0 -0
index 0e03cef72840..378d5a8773c7 100644

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

Quoted 10 lines
drivers/pci/controller/pci-tegra.c +2 -2
@@ -2314,8 +2314,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 			if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
 				rp->reset_gpio = NULL;
 			} else {
-				dev_err(dev, "failed to get reset GPIO: %d\n",
-					err);
+				dev_err(dev, "failed to get reset GPIO: %ld\n",
+					PTR_ERR(rp->reset_gpio));
 				return PTR_ERR(rp->reset_gpio);
 			}
 		}

You can use %pe directly on the pointer for added benefit of translation of the error to a name.

Best Regards,
Michał Mirosław

#2 lore raw
Quoted 18 lines · On Tuesday 14 April 2020 13:31:04 Michał Mirosław wrote:
Quoted 17 lines · Pali Rohár

Error code is stored in rp->reset_gpio and not in err variable.

---
 drivers/pci/controller/pci-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-tegra.c +0 -2
index 0e03cef72840..378d5a8773c7 100644
@@ -2314,8 +2314,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 			if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
 				rp->reset_gpio = NULL;
 			} else {
-				dev_err(dev, "failed to get reset GPIO: %d\n",
-					err);
Quoted 8 lines

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

Quoted 5 lines
drivers/pci/controller/pci-tegra.c +2 -0
+				dev_err(dev, "failed to get reset GPIO: %ld\n",
+					PTR_ERR(rp->reset_gpio));
 				return PTR_ERR(rp->reset_gpio);
 			}
 		}

You can use %pe directly on the pointer for added benefit of translation of the error to a name.

Well, I do not know what is the current preferred style of error messages. On lot of places I see just numeric error numbers.

I did not wanted to change behavior of driver, I just fixed code to report correct error value.

I do not have this hardware, so I cannot test this change. I just spotted this problem when I was looking at other PCI controller drivers how they issue PERST# signal to endpoint cards.

#3 lore raw
Quoted 3 lines · Pali Rohár
Quoted 2 lines · On Tuesday 14 April 2020 13:31:04 Michał Mirosław wrote:
Quoted 1 line · Pali Rohár

Error code is stored in rp->reset_gpio and not in err variable.a

[...]

Quoted 11 lines
Quoted 10 lines

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

Quoted 7 lines
drivers/pci/controller/pci-tegra.c +2 -2
-				dev_err(dev, "failed to get reset GPIO: %d\n",
-					err);
+				dev_err(dev, "failed to get reset GPIO: %ld\n",
+					PTR_ERR(rp->reset_gpio));
 				return PTR_ERR(rp->reset_gpio);
 			}
 		}

You can use %pe directly on the pointer for added benefit of translation of the error to a name.

Quoted 2 lines

Well, I do not know what is the current preferred style of error messages. On lot of places I see just numeric error numbers.

%pe is quite a recent addition to the kernel (since v5.3).

Best Regards
Michał Mirosław

#6 lore raw
In reply to Pali Rohár
Quoted 6 lines · Pali Rohár

Error code is stored in rp->reset_gpio and not in err variable.

---
 drivers/pci/controller/pci-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to pci/tegra, thanks.

Lorenzo

Quoted 18 lines
drivers/pci/controller/pci-tegra.c +2 -2
index 0e03cef72840..378d5a8773c7 100644
@@ -2314,8 +2314,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 			if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
 				rp->reset_gpio = NULL;
 			} else {
-				dev_err(dev, "failed to get reset GPIO: %d\n",
-					err);
+				dev_err(dev, "failed to get reset GPIO: %ld\n",
+					PTR_ERR(rp->reset_gpio));
 				return PTR_ERR(rp->reset_gpio);
 			}
 		}
Signature · 1 line
2.20.1