diff options
author | Michal Suchanek <msuchanek@suse.de> | 2022-10-12 21:57:52 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2022-10-17 21:17:12 -0600 |
commit | 5afe93a18c92a5f08dc6d38c4525e378ffb5067a (patch) | |
tree | bb03c9227817fe28a6add97967a43478994cc4cf /drivers | |
parent | c0648b7b9dc10ed49e2d4b1bedaa5ccd17e23fb3 (diff) |
dm: pci: Fix device PCI iteration
When there is no PCI bus uclass_first_device will return no bus and no
error which will result in pci_find_first_device calling
skip_to_next_device with no bus, and the bus is only checked at the end
of the while cycle, not the beginning.
Fixes: 76c3fbcd3d ("dm: pci: Add a way to iterate through all PCI devices")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/pci-uclass.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 058b2f6359..5cff81ac44 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1217,7 +1217,7 @@ static int skip_to_next_device(struct udevice *bus, struct udevice **devp) * Scan through all the PCI controllers. On x86 there will only be one * but that is not necessarily true on other hardware. */ - do { + while (bus) { device_find_first_child(bus, &dev); if (dev) { *devp = dev; @@ -1226,7 +1226,7 @@ static int skip_to_next_device(struct udevice *bus, struct udevice **devp) ret = uclass_next_device(&bus); if (ret) return ret; - } while (bus); + } return 0; } |