[PATCH] pci: Iterate over busses using uclass_foreach_dev_probe

Marek Vasut via U-Boot <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
Iterate over busses using uclass_foreach_dev_probe() instead of ad-hoc
loop. The uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus) == 0 in
the ad-hoc loop would break on first controller that does not link up
in its .probe() function, which is undesired, as it prevents listing
of PCIe devices on other controllers. Using uclass_get_device_by_seq()
mitigates that problem, and, at the same time, simplifies the code.

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Neil Armstrong <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
 cmd/pci.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/cmd/pci.c b/cmd/pci.c
index 3c0aed50cae..d2a10aec41a 100644
--- a/cmd/pci.c
+++ b/cmd/pci.c
@@ -550,14 +550,10 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		}
 		if (busnum == -1) {
 			if (cmd != 'r') {
-				for (busnum = 0;
-				     uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus) == 0;
-				     busnum++)
+				uclass_foreach_dev_probe(UCLASS_PCI, bus)
 					pciinfo(bus, value, true);
 			} else {
-				for (busnum = 0;
-				     uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus) == 0;
-				     busnum++) {
+				uclass_foreach_dev_probe(UCLASS_PCI, bus) {
 					/* Regions are controller specific so skip non-root buses */
 					if (device_is_on_pci_bus(bus))
 						continue;
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.