Hi Bin, On 28 July 2015 at 01:48, Bin Meng <bmeng...@gmail.com> wrote: > Hi Simon, > > On Tue, Jul 28, 2015 at 5:47 AM, Simon Glass <s...@chromium.org> wrote: >> These functions allow iteration through all PCI devices including bridges. >> The children of each PCI bus are returned in turn. This can be useful for >> configuring, checking or enumerating all the devices. >> >> Signed-off-by: Simon Glass <s...@chromium.org> >> --- >> >> drivers/pci/pci-uclass.c | 58 >> ++++++++++++++++++++++++++++++++++++++++++++++++ >> include/pci.h | 25 +++++++++++++++++++++ >> 2 files changed, 83 insertions(+) >> >> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c >> index 8d3536c..da724ca 100644 >> --- a/drivers/pci/pci-uclass.c >> +++ b/drivers/pci/pci-uclass.c >> @@ -779,6 +779,64 @@ static int pci_bridge_write_config(struct udevice *bus, >> pci_dev_t bdf, >> return pci_bus_write_config(hose->ctlr, bdf, offset, value, size); >> } >> >> +static int skip_to_next_device(struct udevice *bus, struct udevice **devp) >> +{ >> + struct udevice *dev; >> + int ret = 0; >> + >> + do { >> + do { >> + device_find_first_child(bus, &dev); >> + if (dev) { >> + *devp = dev; >> + return 0; >> + } >> + } while (dev); > > There is no need to do a 'do..while' here. > >> + ret = uclass_next_device(&bus); > > I don't understand. If there is no child device of the root pci bus, > why do we bother doing this uclass_next_device()? No child device of > the root pci bus means there will not be another bus device which is > attached to the root pci bus.
That's true on x86, but other hardware may have multiple PCI controllers. I will add a comment. [snip] Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot