Commit 042b83d4c502d17db40f1fa4f6d9b6cb86c653d2
Committed by
Tom Rini
1 parent
1eebd14b79
Exists in
v2017.01-smarct4x
and in
37 other branches
pci: Abort early if bus does not exist
When listing the devices on a PCI bus, the current code will blindly try to access all devices. Internally this causes pci_bus_to_hose() to be repeatedly called and output an error message every time. Prevent this by calling pci_bus_to_hose() once and abort early if no bus was found. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff
common/cmd_pci.c
... | ... | @@ -42,11 +42,15 @@ |
42 | 42 | */ |
43 | 43 | void pciinfo(int BusNum, int ShortPCIListing) |
44 | 44 | { |
45 | + struct pci_controller *hose = pci_bus_to_hose(BusNum); | |
45 | 46 | int Device; |
46 | 47 | int Function; |
47 | 48 | unsigned char HeaderType; |
48 | 49 | unsigned short VendorID; |
49 | 50 | pci_dev_t dev; |
51 | + | |
52 | + if (!hose) | |
53 | + return; | |
50 | 54 | |
51 | 55 | printf("Scanning PCI devices on bus %d\n", BusNum); |
52 | 56 |