From: Gerd Bayer <gbayer@linux•ibm.com>
To: Dave Hansen <dave.hansen@intel•com>,
Richard Henderson <richard.henderson@linaro•org>,
Matt Turner <mattst88@gmail•com>,
Magnus Lindholm <linmag7@gmail•com>,
Russell King <linux@armlinux•org.uk>,
Madhavan Srinivasan <maddy@linux•ibm.com>,
Michael Ellerman <mpe@ellerman•id.au>,
Nicholas Piggin <npiggin@gmail•com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel•org>,
Bjorn Helgaas <bhelgaas@google•com>,
Thomas Gleixner <tglx@kernel•org>, Ingo Molnar <mingo@redhat•com>,
Borislav Petkov <bp@alien8•de>,
Dave Hansen <dave.hansen@linux•intel.com>,
x86@kernel•org, "H. Peter Anvin" <hpa@zytor•com>
Cc: Yinghai Lu <yinghai@kernel•org>,
linux-alpha@vger•kernel.org, linux-kernel@vger•kernel.org,
linux-arm-kernel@lists•infradead.org,
linuxppc-dev@lists•ozlabs.org, linux-pci@vger•kernel.org,
Gerd Bayer <gbayer@linux•ibm.com>
Subject: Re: [PATCH 4/5] x86/pci: Use official API to iterate over PCI buses
Date: Mon, 18 May 2026 14:01:01 +0200 [thread overview]
Message-ID: <c0619e4edfa06764bcbd0ab759f0dd03e3d21041.camel@linux.ibm.com> (raw)
In-Reply-To: <553c703f-ba9c-4785-91ba-2cf62ceb9653@intel.com>
On Fri, 2026-05-15 at 08:13 -0700, Dave Hansen wrote:
> On 5/15/26 07:22, Gerd Bayer wrote:
> > static int __init pcibios_assign_resources(void)
> > {
> > - struct pci_bus *bus;
> > + struct pci_bus *bus = NULL;
> >
> > if (!(pci_probe & PCI_ASSIGN_ROMS))
> > - list_for_each_entry(bus, &pci_root_buses, node)
> > + while ((bus = pci_find_next_bus(bus)) != NULL)
> > pcibios_allocate_rom_resources(bus);
>
> What's with the 'bus = NULL'? I thought there was some crazy macro magic
> going on or something, but pci_find_next_bus() looks like a normal
> function that's just taking a pointer and not _modifying_ the pointer value.
Initializing 'bus = NULL" makes sure, that pci_find_next_bus() starts
at the list head; list_for_each_entry() did that implicitly. I didn't
want to rely on implicit zero-init for local var's on all the various
architectures. But I'm fine to drop it here, if you prefer.
>
> Also, wouldn't this be a more readable way of writing what you have?
>
> while (bus = pci_find_next_bus(bus))
Yeah, another occasion of me being (overly?) verbose.
arch/sparc/kernel/pci.c was my blueprint. Again, something that I'm ok
to drop.
>
> For that matter isn't the kernel idiom for these things:
>
> for_each_pci_bus(bus) {
> // do bus stuff
> }
>
> I'm kinda surprised there isn't one of those already.
Just guessing: There was too little use of pci_find_next_bus() to
warrant that short-cut. But I can make a proposal in the next
iteration.
Thanks,
Gerd
next prev parent reply other threads:[~2026-05-18 12:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 14:22 [PATCH 0/5] PCI: Finally make pci_root_buses private Gerd Bayer
2026-05-15 14:22 ` [PATCH 1/5] alpha/pci: Use official API to iterate over PCI buses Gerd Bayer
2026-05-15 14:22 ` [PATCH 2/5] arm/pci: " Gerd Bayer
2026-05-18 15:45 ` Gerd Bayer
2026-05-15 14:22 ` [PATCH 3/5] powerpc/pci: " Gerd Bayer
2026-05-15 14:22 ` [PATCH 4/5] x86/pci: " Gerd Bayer
2026-05-15 15:13 ` Dave Hansen
2026-05-18 12:01 ` Gerd Bayer [this message]
2026-05-15 14:22 ` [PATCH 5/5] PCI: Make pci_root_buses private to PCI core Gerd Bayer
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=c0619e4edfa06764bcbd0ab759f0dd03e3d21041.camel@linux.ibm.com \
--to=gbayer@linux$(echo .)ibm.com \
--cc=bhelgaas@google$(echo .)com \
--cc=bp@alien8$(echo .)de \
--cc=chleroy@kernel$(echo .)org \
--cc=dave.hansen@intel$(echo .)com \
--cc=dave.hansen@linux$(echo .)intel.com \
--cc=hpa@zytor$(echo .)com \
--cc=linmag7@gmail$(echo .)com \
--cc=linux-alpha@vger$(echo .)kernel.org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-pci@vger$(echo .)kernel.org \
--cc=linux@armlinux$(echo .)org.uk \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=maddy@linux$(echo .)ibm.com \
--cc=mattst88@gmail$(echo .)com \
--cc=mingo@redhat$(echo .)com \
--cc=mpe@ellerman$(echo .)id.au \
--cc=npiggin@gmail$(echo .)com \
--cc=richard.henderson@linaro$(echo .)org \
--cc=tglx@kernel$(echo .)org \
--cc=x86@kernel$(echo .)org \
--cc=yinghai@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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