From: Majed Alkhaleefah <majedalkhaleefah@gmail.com>
To: bhelgaas@google.com
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
scott@spiteful.org,
Majed Alkhaleefah <majedalkhaleefah@gmail.com>
Subject: [PATCH v2] PCI: hotplug: Change return type of pci_hp_add_bridge() to void
Date: Tue, 24 Feb 2026 18:00:37 +0000 [thread overview]
Message-ID: <20260224180036.361502-2-majedalkhaleefah@gmail.com> (raw)
In-Reply-To: <20260223023645.344137-2-majedalkhaleefah@gmail.com>
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@google.com>
Signed-off-by: Majed Alkhaleefah <majedalkhaleefah@gmail.com>
---
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
next prev parent reply other threads:[~2026-02-24 18:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 2:36 [PATCH] PCI: cpcihp: Check pci_hp_add_bridge() return value Majed Alkhaleefah
2026-02-23 17:26 ` Bjorn Helgaas
2026-02-24 18:00 ` Majed Alkhaleefah [this message]
2026-03-17 22:49 ` [PATCH v2] PCI: hotplug: Change return type of pci_hp_add_bridge() to void Majed Alkhaleefah
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260224180036.361502-2-majedalkhaleefah@gmail.com \
--to=majedalkhaleefah@gmail.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=scott@spiteful.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®