Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: udc: core: Warn about failed to find udc
@ 2020-01-04 11:28 Dejin Zheng
  2020-01-04 11:45 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Dejin Zheng @ 2020-01-04 11:28 UTC (permalink / raw)
  To: balbi, gregkh, stern, rogerq; +Cc: linux-usb, linux-kernel, Dejin Zheng

If we do not warn here, the user may not know failed to
find udc class driver because it silently fails.
Let's print a warning in that case so developers find
these problems faster.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
 drivers/usb/gadget/udc/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 51fa614b4079..9b11046480fe 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1414,6 +1414,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
 	}
 
 	mutex_unlock(&udc_lock);
+	if (ret)
+		pr_warn("udc-core: couldn't find an available UDC or it's busy\n");
 	return ret;
 found:
 	ret = udc_bind_to_driver(udc, driver);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: udc: core: Warn about failed to find udc
  2020-01-04 11:28 [PATCH] usb: gadget: udc: core: Warn about failed to find udc Dejin Zheng
@ 2020-01-04 11:45 ` Greg KH
  2020-01-04 13:09   ` Dejin Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-01-04 11:45 UTC (permalink / raw)
  To: Dejin Zheng; +Cc: balbi, stern, rogerq, linux-usb, linux-kernel

On Sat, Jan 04, 2020 at 07:28:36PM +0800, Dejin Zheng wrote:
> If we do not warn here, the user may not know failed to
> find udc class driver because it silently fails.
> Let's print a warning in that case so developers find
> these problems faster.
> 
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> ---
>  drivers/usb/gadget/udc/core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 51fa614b4079..9b11046480fe 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -1414,6 +1414,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
>  	}
>  
>  	mutex_unlock(&udc_lock);
> +	if (ret)
> +		pr_warn("udc-core: couldn't find an available UDC or it's busy\n");
>  	return ret;
>  found:
>  	ret = udc_bind_to_driver(udc, driver);
> -- 
> 2.17.1
> 

Isn't this going to cause a lot more messages than is really needed?

And as you have a device, shouldn't this be dev_warn()?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: udc: core: Warn about failed to find udc
  2020-01-04 11:45 ` Greg KH
@ 2020-01-04 13:09   ` Dejin Zheng
  0 siblings, 0 replies; 3+ messages in thread
From: Dejin Zheng @ 2020-01-04 13:09 UTC (permalink / raw)
  To: Greg KH; +Cc: balbi, stern, rogerq, linux-usb, linux-kernel

On Sat, Jan 04, 2020 at 12:45:30PM +0100, Greg KH wrote:
> On Sat, Jan 04, 2020 at 07:28:36PM +0800, Dejin Zheng wrote:
> > If we do not warn here, the user may not know failed to
> > find udc class driver because it silently fails.
> > Let's print a warning in that case so developers find
> > these problems faster.
> > 
> > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> > ---
> >  drivers/usb/gadget/udc/core.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > index 51fa614b4079..9b11046480fe 100644
> > --- a/drivers/usb/gadget/udc/core.c
> > +++ b/drivers/usb/gadget/udc/core.c
> > @@ -1414,6 +1414,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
> >  	}
> >  
> >  	mutex_unlock(&udc_lock);
> > +	if (ret)
> > +		pr_warn("udc-core: couldn't find an available UDC or it's busy\n");
> >  	return ret;
> >  found:
> >  	ret = udc_bind_to_driver(udc, driver);
> > -- 
> > 2.17.1
> > 
> 
> Isn't this going to cause a lot more messages than is really needed?

I think this should not happen. here just for a gadget driver to find
an udc device by the same name. one driver only call this function once.
if it found, the udc device will bind this driver. otherwise, print this
warning.

I also searched for the caller of this function, For example:
gadget_dev_desc_UDC_store() and usb_composite_probe(), They also
failed silently without any warning messages for return error of
this function. 

> 
> And as you have a device, shouldn't this be dev_warn()?

Sorry, my comments has some mistake. I did not have a device when the
gadget driver failed to find an udc device by the same name. I will
fix it on patch v2.

> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-04 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-04 11:28 [PATCH] usb: gadget: udc: core: Warn about failed to find udc Dejin Zheng
2020-01-04 11:45 ` Greg KH
2020-01-04 13:09   ` Dejin Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox