[U-Boot] [PATCH] cmd_pci: Check for VendorID earlier

Fabio Estevam festevam at gmail.com
Thu Oct 8 01:37:31 CEST 2015


From: Fabio Estevam <fabio.estevam at freescale.com>

Since commit ff3e077bd2 ("dm: pci: Add a uclass for PCI") the following
error message is seen:

=> pci 0
Scanning PCI devices on bus 0
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
00.01.00   0x16c3     0xabcd     Bridge device           0x04
Cannot read bus configuration: -1

=> pci 1
Scanning PCI devices on bus 1
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
01.00.00   0x8086     0x08b1     Network controller      0x80
Cannot read bus configuration: -1

When we are done scanning the PCI devices pci_read_config_word() will
return -1 and VendorID will contain 0xFFFF.

The original code would exit the 'for' loop in this condition.

Keep the same original behaviour by first testing the VendorID value
and then checking and propagating the pci_read_config_word() error
afterwards.

Signed-off-by: Fabio Estevam <fabio.estevam at freescale.com>
---
 common/cmd_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index dcecef8..92dc643 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -77,10 +77,10 @@ void pciinfo(int BusNum, int ShortPCIListing)
 
 			ret = pci_read_config_word(dev, PCI_VENDOR_ID,
 						   &VendorID);
-			if (ret)
-				goto error;
 			if ((VendorID == 0xFFFF) || (VendorID == 0x0000))
 				continue;
+			if (ret)
+				goto error;
 
 			if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType);
 
-- 
1.9.1



More information about the U-Boot mailing list