Re: [PATCH 4/5] x86/pci: Use official API to iterate over PCI buses

From
Dave Hansen <hidden>
Date
2026-05-15 15:13:15
Also in
linux-alpha, linux-arm-kernel, linux-pci, lkml
Reply to
Gerd Bayer, 2026-05-15
On 5/15/26 07:22, Gerd Bayer wrote:
quoted hunk ↗ jump to hunk
 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.

Also, wouldn't this be a more readable way of writing what you have?

	while (bus = pci_find_next_bus(bus))

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.
Thread (9 messages) 9 messages, 2 authors, last reply 2026-05-18
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help