[PATCH v2] PCI: hotplug: Change return type of pci_hp_add_bridge() to void

From: Majed Alkhaleefah

Date: Tue Feb 24 2026 - 13:21:40 EST


The function pci_hp_add_bridge() currently returns an int error code.
However, none of its callers actually check or store the return value,
neither do they need to take any special action in the event of a
failure.

The execution path of pci_hp_add_bridge() already contains relevant
error logging. Therefore, adding additional logging/error checking is
redundant.

Make pci_hp_add_bridge() a void function.

Compile-tested only.

Suggested-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Signed-off-by: Majed Alkhaleefah <majedalkhaleefah@xxxxxxxxx>
---
Thank you for the review. Looking at the path of
pci_hp_add_bridge(), adding additional error checking is indeed
redundant, and the function could just be made to return void.

Changes in v2:
- Drop the v1 approach of checking the return value of
pci_hp_add_bridge() in cpci_configure_slot()
- Remove relevant TODO items
- Make pci_hp_add_bridge() a void function

drivers/pci/hotplug/TODO | 8 --------
drivers/pci/pci.h | 2 +-
drivers/pci/probe.c | 9 ++-------
3 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/hotplug/TODO b/drivers/pci/hotplug/TODO
index 7397374af171..2a4f44f9b629 100644
--- a/drivers/pci/hotplug/TODO
+++ b/drivers/pci/hotplug/TODO
@@ -1,9 +1,5 @@
Contributions are solicited in particular to remedy the following issues:

-cpcihp:
-
-* Returned code from pci_hp_add_bridge() is not checked.
-
cpqphp:

* The driver spawns a kthread cpqhp_event_thread() which is woken by the
@@ -14,8 +10,6 @@ cpqphp:
* A large portion of cpqphp_ctrl.c and cpqphp_pci.c concerns resource
management. Doesn't this duplicate functionality in the core?

-* Returned code from pci_hp_add_bridge() is not checked.
-
ibmphp:

* Implementations of hotplug_slot_ops callbacks such as get_adapter_present()
@@ -43,8 +37,6 @@ ibmphp:
* A large portion of ibmphp_res.c and ibmphp_pci.c concerns resource
management. Doesn't this duplicate functionality in the core?

-* Returned code from pci_hp_add_bridge() is not checked.
-
shpchp:

* The hardirq handler shpc_isr() queues events on a workqueue. It can be
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 13d998fbacce..ee35f5582688 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -353,7 +353,7 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }
#endif

/* Functions for PCI Hotplug drivers to use */
-int pci_hp_add_bridge(struct pci_dev *dev);
+void pci_hp_add_bridge(struct pci_dev *dev);
bool pci_hp_spurious_link_change(struct pci_dev *pdev);

#if defined(CONFIG_SYSFS) && defined(HAVE_PCI_LEGACY)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bccc7a4bdd79..b4270e44a769 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3545,7 +3545,7 @@ void __init pci_sort_breadthfirst(void)
bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp);
}

-int pci_hp_add_bridge(struct pci_dev *dev)
+void pci_hp_add_bridge(struct pci_dev *dev)
{
struct pci_bus *parent = dev->bus;
int busnr, start = parent->busn_res.start;
@@ -3558,7 +3558,7 @@ int pci_hp_add_bridge(struct pci_dev *dev)
}
if (busnr-- > end) {
pci_err(dev, "No bus number available for hot-added bridge\n");
- return -1;
+ return;
}

/* Scan bridges that are already configured */
@@ -3572,10 +3572,5 @@ int pci_hp_add_bridge(struct pci_dev *dev)

/* Scan bridges that need to be reconfigured */
pci_scan_bridge_extend(parent, dev, busnr, available_buses, 1);
-
- if (!dev->subordinate)
- return -1;
-
- return 0;
}
EXPORT_SYMBOL_GPL(pci_hp_add_bridge);
--
2.43.0