[U-Boot] [PATCH 1/2] usb: dm: Add a usb_for_each_root_dev() helper function

Marek Vasut marex at denx.de
Mon Jul 4 14:29:00 CEST 2016


On 07/03/2016 08:22 PM, Hans de Goede wrote:
> 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 at redhat.com>

Applied, thanks.

> ---
>  cmd/usb.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/cmd/usb.c b/cmd/usb.c
> index 58d9db2..5453c0d 100644
> --- a/cmd/usb.c
> +++ b/cmd/usb.c
> @@ -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;
>


-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list