Index: src/mainboard/via/epia-m/Options.lb
===================================================================
--- src/mainboard/via/epia-m/Options.lb	(revision 2269)
+++ src/mainboard/via/epia-m/Options.lb	(working copy)
@@ -38,6 +38,7 @@
 uses CONFIG_UDELAY_TSC
 uses CONFIG_PCI_ROM_RUN
 uses CONFIG_CONSOLE_VGA
+uses CONFIG_MAX_PCI_BUSES 
 
 ## ROM_SIZE is the size of boot ROM that this board will use.
 default ROM_SIZE  = 256*1024
@@ -121,5 +122,14 @@
 default CC="$(CROSS_COMPILE)gcc -m32"
 default HOSTCC="gcc"
 
+##
+## Set this to the max PCI bus number you 
+## would ever use for PCI config IO.
+## Setting this number very high will make 
+## pci_locate_device take a long time when
+## it can't find a device.
+##
+default CONFIG_MAX_PCI_BUSES = 5	 
+
 end
 
Index: src/mainboard/via/epia-m/auto.c
===================================================================
--- src/mainboard/via/epia-m/auto.c	(revision 2269)
+++ src/mainboard/via/epia-m/auto.c	(working copy)
@@ -120,7 +120,6 @@
 	if (dev != PCI_DEV_INVALID) {
 		pci_write_config8(dev, 0x15, 0x1c);
 	}
-
 	enable_smbus();
 	
 	enable_vt8235_serial();
Index: src/config/Options.lb
===================================================================
--- src/config/Options.lb	(revision 2269)
+++ src/config/Options.lb	(working copy)
@@ -490,6 +490,11 @@
 	export used
 	comment "System clock frequency in MHz"
 end
+define CONFIG_MAX_PCI_BUSES
+	default 5
+	export always
+	comment "Maximum number of PCI buses to search for devices"
+end
 ###############################################
 # SMP options
 ###############################################
Index: src/arch/i386/include/arch/romcc_io.h
===================================================================
--- src/arch/i386/include/arch/romcc_io.h	(revision 2269)
+++ src/arch/i386/include/arch/romcc_io.h	(working copy)
@@ -168,7 +168,7 @@
 #define PCI_DEV_INVALID (0xffffffffU)
 static device_t pci_locate_device(unsigned pci_id, device_t dev)
 {
-	for(; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0,0,1)) {
+	for(; dev <= PCI_DEV(CONFIG_MAX_PCI_BUSES, 31, 7); dev += PCI_DEV(0,0,1)) {
 		unsigned int id;
 		id = pci_read_config32(dev, 0);
 		if (id == pci_id) {
