PCI: Use %pe format specifier to print error pointers
Subsystems (10)
Krzysztof Wilczyński
maintainerPATCH 1/1 PCI: Use %pe format specifier to print error pointers
Currently, several files in the PCI tree print error pointers using the %ld format specifier together with an explicit PTR_ERR() conversion, which prints the numeric errno value.
Thus, at every affected call site, use the %pe format specifier, which exists specifically to print error pointers, and pass the error pointer directly. With CONFIG_SYMBOLIC_ERRNAME enabled, this prints a symbolic error name such as -ENOMEM, falling back to the numeric errno value otherwise. As such, the explicit PTR_ERR() conversion is no longer needed.
No functional changes intended.
--- drivers/pci/controller/dwc/pci-meson.c | 2 +- drivers/pci/controller/dwc/pcie-tegra194.c | 16 ++++++++-------- drivers/pci/controller/pci-aardvark.c | 2 +- drivers/pci/controller/pci-tegra.c | 3 +-- drivers/pci/controller/pcie-rockchip.c | 4 ++-- drivers/pci/doe.c | 4 ++-- drivers/pci/pci-acpi.c | 4 ++-- 7 files changed, 17 insertions(+), 18 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +1 -1
@@ -398,7 +398,7 @@ static int meson_pcie_probe(struct platform_device *pdev) mp->phy =devm_phy_get (dev,"pcie" );if (IS_ERR (mp->phy)) { -dev_err (dev,"get phy failed, %ld\n" ,PTR_ERR (mp->phy)); +dev_err (dev,"get phy failed, %pe\n" , mp->phy);return PTR_ERR (mp->phy); }
drivers/pci/controller/dwc/pcie-tegra194.c +8 -8
@@ -2196,15 +2196,15 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev)if (IS_ERR (pcie->pex_ctl_supply)) { ret =PTR_ERR (pcie->pex_ctl_supply);if (ret != -EPROBE_DEFER ) -dev_err (dev,"Failed to get regulator: %ld\n" , -PTR_ERR (pcie->pex_ctl_supply)); +dev_err (dev,"Failed to get regulator: %pe\n" , + pcie->pex_ctl_supply);return ret; } pcie->core_clk =devm_clk_get (dev,"core" );if (IS_ERR (pcie->core_clk)) { -dev_err (dev,"Failed to get core clock: %ld\n" , -PTR_ERR (pcie->core_clk)); +dev_err (dev,"Failed to get core clock: %pe\n" , + pcie->core_clk);return PTR_ERR (pcie->core_clk); }
@@ -2226,8 +2226,8 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) pcie->core_apb_rst =devm_reset_control_get (dev,"apb" );if (IS_ERR (pcie->core_apb_rst)) { -dev_err (dev,"Failed to get APB reset: %ld\n" , -PTR_ERR (pcie->core_apb_rst)); +dev_err (dev,"Failed to get APB reset: %pe\n" , + pcie->core_apb_rst);return PTR_ERR (pcie->core_apb_rst); }
@@ -2268,8 +2268,8 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) pcie->core_rst =devm_reset_control_get (dev,"core" );if (IS_ERR (pcie->core_rst)) { -dev_err (dev,"Failed to get core reset: %ld\n" , -PTR_ERR (pcie->core_rst)); +dev_err (dev,"Failed to get core reset: %pe\n" , + pcie->core_rst);return PTR_ERR (pcie->core_rst); }
drivers/pci/controller/pci-aardvark.c +1 -1
@@ -1722,7 +1722,7 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie)/* Old bindings miss the PHY handle */ if (IS_ERR (pcie->phy)) { -dev_warn (dev,"PHY unavailable (%ld)\n" ,PTR_ERR (pcie->phy)); +dev_warn (dev,"PHY unavailable (%pe)\n" , pcie->phy); pcie->phy =NULL ;return 0 ; }
drivers/pci/controller/pci-tegra.c +1 -2
@@ -1356,8 +1356,7 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)for (i =0 ; i < port->lanes; i++) { phy =devm_of_phy_optional_get_index (dev, port->np,"pcie" , i);if (IS_ERR (phy)) { -dev_err (dev,"failed to get PHY#%u: %ld\n" , i, -PTR_ERR (phy)); +dev_err (dev,"failed to get PHY#%u: %pe\n" , i, phy);return PTR_ERR (phy); }
drivers/pci/controller/pcie-rockchip.c +2 -2
@@ -232,8 +232,8 @@ int rockchip_pcie_get_phys(struct rockchip_pcie *rockchip)if (IS_ERR (phy)) {if (PTR_ERR (phy) != -EPROBE_DEFER ) -dev_err (dev,"missing phy for lane %d: %ld\n" , - i,PTR_ERR (phy)); +dev_err (dev,"missing phy for lane %d: %pe\n" , + i, phy);return PTR_ERR (phy); }
drivers/pci/doe.c +2 -2
@@ -858,8 +858,8 @@ void pci_doe_init(struct pci_dev *pdev) PCI_EXT_CAP_ID_DOE))) { doe_mb =pci_doe_create_mb (pdev, offset);if (IS_ERR (doe_mb)) { -pci_err (pdev,"[%x] failed to create mailbox: %ld\n" , - offset,PTR_ERR (doe_mb)); +pci_err (pdev,"[%x] failed to create mailbox: %pe\n" , + offset, doe_mb);continue ; }
drivers/pci/pci-acpi.c +2 -2
@@ -1636,8 +1636,8 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root) cfg =pci_ecam_create (dev, &cfgres, bus_res, ecam_ops);if (IS_ERR (cfg)) { -dev_err (dev,"%04x:%pR error %ld mapping ECAM\n" , seg, bus_res, -PTR_ERR (cfg)); +dev_err (dev,"%04x:%pR error %pe mapping ECAM\n" , seg, bus_res, + cfg);return NULL ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
Currently, several files in the PCI tree print error pointers using the %ld format specifier together with an explicit
PTR_ERR()conversion, which prints the numeric errno value.Thus, at every affected call site, use the %pe format specifier, which exists specifically to print error pointers, and pass the error pointer directly. With
CONFIG_SYMBOLIC_ERRNAMEenabled, this prints a symbolic error name such as-ENOMEM, falling back to the numeric errno value otherwise. As such, the explicitPTR_ERR()conversion is no longer needed.
Quoted 3 lines
No functional changes intended.
Signed-off-by Krzysztof Wilczyński <[email protected]>
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
Hello,
Quoted 4 lines
Currently, several files in the PCI tree print error pointers using the %ld format specifier together with an explicit
PTR_ERR()conversion, which prints the numeric errno value.
Quoted 8 lines
Thus, at every affected call site, use the %pe format specifier, which exists specifically to print error pointers, and pass the error pointer directly. With
CONFIG_SYMBOLIC_ERRNAMEenabled, this prints a symbolic error name such as-ENOMEM, falling back to the numeric errno value otherwise. As such, the explicitPTR_ERR()conversion is no longer needed.No functional changes intended.
Applied to the misc branch.
Thank you!
Krzysztof