[U-Boot] [PATCH 1/5] dm: usb: Move printing of usb scan status to usb_scan_bus()

Simon Glass sjg at chromium.org
Tue May 5 23:45:41 CEST 2015


Hi Hans,

On 5 May 2015 at 07:28, Hans de Goede <hdegoede at redhat.com> wrote:
> Move printing of usb scan status to usb_scan_bus().
>
> This is a preparation patch for adding companion controller support to the
> usb uclass.
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  drivers/usb/host/usb-uclass.c | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)

Acked-by: Simon Glass <sjg at chromium.org>

>
> diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
> index 9ee25ed..ad778b4 100644
> --- a/drivers/usb/host/usb-uclass.c
> +++ b/drivers/usb/host/usb-uclass.c
> @@ -147,7 +147,7 @@ int usb_stop(void)
>         return err;
>  }
>
> -static int usb_scan_bus(struct udevice *bus, bool recurse)
> +static void usb_scan_bus(struct udevice *bus, bool recurse)
>  {
>         struct usb_bus_priv *priv;
>         struct udevice *dev;
> @@ -157,11 +157,15 @@ static int usb_scan_bus(struct udevice *bus, bool recurse)
>
>         assert(recurse);        /* TODO: Support non-recusive */
>
> +       printf("scanning bus %d for devices... ", bus->seq);
> +       debug("\n");
>         ret = usb_scan_device(bus, 0, USB_SPEED_FULL, &dev);
>         if (ret)
> -               return ret;
> -
> -       return priv->next_addr;
> +               printf("failed, error %d\n", ret);
> +       else if (priv->next_addr == 0)
> +               printf("No USB Device found\n");
> +       else
> +               printf("%d USB Device(s) found\n", priv->next_addr);

I'd like to keep printf() out of the uclasses and this buries it two
levels deep. Still I don't think it is too hard to unpick. I think
perhaps one day we should move usb_init() back to usb.c and put all
the logic there.

>  }
>
>  int usb_init(void)
> @@ -199,15 +203,7 @@ int usb_init(void)
>                  * i.e. search HUBs and configure them
>                  */
>                 controllers_initialized++;
> -               printf("scanning bus %d for devices... ", bus->seq);
> -               debug("\n");
> -               ret = usb_scan_bus(bus, true);
> -               if (ret < 0)
> -                       printf("failed, error %d\n", ret);
> -               else if (!ret)
> -                       printf("No USB Device found\n");
> -               else
> -                       printf("%d USB Device(s) found\n", ret);
> +               usb_scan_bus(bus, true);
>                 usb_started = true;
>         }
>
> --
> 2.3.6
>
Regards,
Simon


More information about the U-Boot mailing list