diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0b6a8bb183e32b7350ec7d2559785f1b33439410..2f9b7606b933c92a3e8975e27f96726ea6283114 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -55,11 +55,11 @@ pci_bus_max_busnr(struct pci_bus* bus)
 unsigned char __devinit
 pci_max_busnr(void)
 {
-	struct pci_bus* bus;
+	struct pci_bus *bus = NULL;
 	unsigned char max, n;
 
 	max = 0;
-	pci_for_each_bus(bus) {
+	while ((bus = pci_find_next_bus(bus)) != NULL) {
 		n = pci_bus_max_busnr(bus);
 		if(n > max)
 			max = n;