All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	Marek Vasut <marex@denx.de>, Lukasz Majewski <lukma@denx.de>
Cc: u-boot@lists.denx.de, Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH RESEND v2 2/2] usb: udc: Try to clarify an error message
Date: Thu, 05 Oct 2023 14:33:17 +0200	[thread overview]
Message-ID: <87pm1tb65u.fsf@baylibre.com> (raw)
In-Reply-To: <20231002134621.94786-2-miquel.raynal@bootlin.com>

On lun., oct. 02, 2023 at 15:46, Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> At some point when trying to use USB gadgets, two situations may arise
> and lead to a failure. Either the UDC (USB Device Controller) is not
> available at all (not described or not probed) or the UDC is already in
> use. For instance, as the USB Ethernet gadget remains bound to the UDC,
> the use of any other USB gadget (fastboot, dfu, etc) *after* will always
> fail with the "couldn't find an available UDC" error.
>
> Let's give a more helpful message by making a difference between the two
> cases. Let's also hint people who would get this error and grep it into
> the sources a better explanation of what's wrong with their workflow.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
> While doing this I really wanted to add "much more" error comments but I
> faced another reality: often the messages are there but use
> pr_err/log_err which is actually silenced by default with LOGLEVEL=3, so
> I consider this unnecessary, as decreasing the loglevel will make these
> messages appear. I would have expected errors to be displayed, but I
> understand it makes the binaries even bigger.
>
> Resend: no change.
>
> Changes in v2:
> * s/UDC/UDCs/. I kept the sentence as it was as the suggested form did
>   not sound well at all when there is only one UDC.
> ---
>  drivers/usb/gadget/udc/udc-core.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
> index 7f73926cb3e..8405b03462e 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -323,6 +323,7 @@ err1:
>  int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
>  {
>  	struct usb_udc		*udc = NULL;
> +	unsigned int		udc_count = 0;
>  	int			ret;
>  
>  	if (!driver || !driver->bind || !driver->setup)
> @@ -330,12 +331,22 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
>  
>  	mutex_lock(&udc_lock);
>  	list_for_each_entry(udc, &udc_list, list) {
> +		udc_count++;
> +
>  		/* For now we take the first one */
>  		if (!udc->driver)
>  			goto found;
>  	}
>  
> -	printf("couldn't find an available UDC\n");
> +	if (!udc_count)
> +		printf("No UDC available in the system\n");
> +	else
> +		/* When this happens, users should 'unbind <class> <index>'
> +		 * using the output of 'dm tree' and looking at the line right
> +		 * after the USB peripheral/device controller.
> +		 */
> +		printf("All UDCs in use (%d available), use the unbind command\n",
> +		       udc_count);
>  	mutex_unlock(&udc_lock);
>  	return -ENODEV;
>  found:
> -- 
> 2.34.1

  parent reply	other threads:[~2023-10-05 12:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 13:46 [PATCH RESEND v2 1/2] cmd: bind: Try to improve the (un)bind help Miquel Raynal
2023-10-02 13:46 ` [PATCH RESEND v2 2/2] usb: udc: Try to clarify an error message Miquel Raynal
2023-10-02 14:37   ` Massimo Pegorer
2023-10-02 15:01     ` Miquel Raynal
2023-10-05 12:33   ` Mattijs Korpershoek [this message]
2023-10-05 13:04   ` Marek Vasut
2023-10-05 15:51     ` Miquel Raynal
2023-10-07 21:09       ` Marek Vasut
2023-10-10  8:34         ` Miquel Raynal
2023-10-02 18:56 ` [PATCH RESEND v2 1/2] cmd: bind: Try to improve the (un)bind help Simon Glass
2023-10-05 12:30 ` Mattijs Korpershoek
2023-10-05 13:01 ` Marek Vasut
2023-10-05 15:54   ` Miquel Raynal
2023-10-07 21:03     ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pm1tb65u.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=miquel.raynal@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.