From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 3/3] PCI: Cleanup pci_scan_child_bus_extend() loop
Date: Tue, 10 Jun 2025 13:58:20 +0300 [thread overview]
Message-ID: <20250610105820.7126-3-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20250610105820.7126-1-ilpo.jarvinen@linux.intel.com>
pci_scan_child_bus_extend() open-codes device number iteration in the
for loop. Convert to use PCI_DEVFN() and add PCI_MAX_NR_DEVS (there
seems to be no pre-existing defines for this purpose).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/pci.h | 1 +
drivers/pci/probe.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 12215ee72afb..caa6e02a9aea 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -8,6 +8,7 @@ struct pcie_tlp_log;
/* Number of possible devfns: 0.0 to 1f.7 inclusive */
#define MAX_NR_DEVFNS 256
+#define PCI_MAX_NR_DEVS 32
#define MAX_NR_LANES 16
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f08e754c404b..963cab481327 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3029,14 +3029,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
{
unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0;
unsigned int start = bus->busn_res.start;
- unsigned int devfn, cmax, max = start;
+ unsigned int devnr, cmax, max = start;
struct pci_dev *dev;
dev_dbg(&bus->dev, "scanning bus\n");
/* Go find them, Rover! */
- for (devfn = 0; devfn < 256; devfn += 8)
- pci_scan_slot(bus, devfn);
+ for (devnr = 0; devnr < PCI_MAX_NR_DEVS; devnr++)
+ pci_scan_slot(bus, PCI_DEVFN(devnr, 0));
/* Reserve buses for SR-IOV capability */
used_buses = pci_iov_bus_range(bus);
--
2.39.5
next prev parent reply other threads:[~2025-06-10 10:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 10:58 [PATCH 1/3] PCI: Use header type defines in pci_setup_device() Ilpo Järvinen
2025-06-10 10:58 ` [PATCH 2/3] PCI: Cleanup early_dump_pci_device() Ilpo Järvinen
2025-06-10 14:26 ` Sathyanarayanan Kuppuswamy
2025-06-10 10:58 ` Ilpo Järvinen [this message]
2025-06-10 14:28 ` [PATCH 3/3] PCI: Cleanup pci_scan_child_bus_extend() loop Sathyanarayanan Kuppuswamy
2025-06-10 14:26 ` [PATCH 1/3] PCI: Use header type defines in pci_setup_device() Sathyanarayanan Kuppuswamy
2025-08-06 22:56 ` Bjorn Helgaas
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=20250610105820.7126-3-ilpo.jarvinen@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.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