diff options
author | Hans de Goede <hdegoede@redhat.com> | 2016-07-03 20:22:04 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2016-07-05 14:14:11 +0200 |
commit | 2138fd6d5d358bcfef6631300763c16a70f2af3d (patch) | |
tree | 8d2d9b908a697d1c479988ec05d4f35f06201093 /cmd | |
parent | e8009beff6d5c55c1bf1ae8184791f167e6378b0 (diff) | |
download | u-boot-2138fd6d5d358bcfef6631300763c16a70f2af3d.tar.gz u-boot-2138fd6d5d358bcfef6631300763c16a70f2af3d.tar.bz2 u-boot-2138fd6d5d358bcfef6631300763c16a70f2af3d.zip |
usb: dm: Add a usb_for_each_root_dev() helper function
Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/usb.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -438,9 +438,11 @@ static void usb_show_subtree(struct usb_device *dev) usb_show_tree_graph(dev, &preamble[0]); } -void usb_show_tree(void) -{ #ifdef CONFIG_DM_USB +typedef void (*usb_dev_func_t)(struct usb_device *udev); + +static void usb_for_each_root_dev(usb_dev_func_t func) +{ struct udevice *bus; for (uclass_find_first_device(UCLASS_USB, &bus); @@ -455,9 +457,16 @@ void usb_show_tree(void) device_find_first_child(bus, &dev); if (dev && device_active(dev)) { udev = dev_get_parent_priv(dev); - usb_show_subtree(udev); + func(udev); } } +} +#endif + +void usb_show_tree(void) +{ +#ifdef CONFIG_DM_USB + usb_for_each_root_dev(usb_show_subtree); #else struct usb_device *udev; int i; |