[PATCH 2/2] PCI: Print the error code when PCI sysfs or procfs creation fails

Jinhui Guo posted 2 patches 4 months ago
[PATCH 2/2] PCI: Print the error code when PCI sysfs or procfs creation fails
Posted by Jinhui Guo 4 months ago
pci_bus_add_device() ignores the return values of
pci_create_sysfs_dev_files() and pci_proc_attach_device(), so any
sysfs/procfs creation errors are silently lost. To make PCI
bring-up failures easier to diagnose, log the errno returned by
pci_create_sysfs_dev_files() and pci_proc_attach_device() in
pci_bus_add_device().

Signed-off-by: Jinhui Guo <guojinhui.liam@bytedance.com>
---
 drivers/pci/bus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index f26aec6ff588..395a1c7bb4c7 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -344,6 +344,7 @@ void pci_bus_add_device(struct pci_dev *dev)
 {
 	struct device_node *dn = dev->dev.of_node;
 	struct platform_device *pdev;
+	int ret;
 
 	/*
 	 * Can not put in pci_device_add yet because resources
@@ -353,8 +354,12 @@ void pci_bus_add_device(struct pci_dev *dev)
 	pci_fixup_device(pci_fixup_final, dev);
 	if (pci_is_bridge(dev))
 		of_pci_make_dev_node(dev);
-	pci_create_sysfs_dev_files(dev);
-	pci_proc_attach_device(dev);
+	ret = pci_create_sysfs_dev_files(dev);
+	if (ret)
+		pci_err(dev, "created sysfs files error %d\n", ret);
+	ret = pci_proc_attach_device(dev);
+	if (ret)
+		pci_err(dev, "created procfs files error %d\n", ret);
 	pci_bridge_d3_update(dev);
 
 	/*
-- 
2.20.1