All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: fotg210-hcd: Fix an error message
@ 2021-05-06 20:39 Christophe JAILLET
  2021-05-07  2:20 ` Chunfeng Yun
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2021-05-06 20:39 UTC (permalink / raw)
  To: gregkh, shubhankarvk, lee.jones, gustavoars, vulab, chunfeng.yun,
	john453
  Cc: linux-usb, linux-kernel, kernel-janitors, Christophe JAILLET

'retval' is known to be -ENODEV here.
This is a hard-coded default error code which is not useful in the error
message. Moreover, another error message is printed at the end of the
error handling path. The corresponding error code (-ENOMEM) is more
informative.

So remove simplify the first error message.

While at it, also remove the useless initialization of 'retval'.

Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/usb/host/fotg210-hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 6cac642520fc..9c2eda0918e1 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -5568,7 +5568,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
 	struct usb_hcd *hcd;
 	struct resource *res;
 	int irq;
-	int retval = -ENODEV;
+	int retval;
 	struct fotg210_hcd *fotg210;
 
 	if (usb_disabled())
@@ -5588,7 +5588,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
 	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
 			dev_name(dev));
 	if (!hcd) {
-		dev_err(dev, "failed to create hcd with err %d\n", retval);
+		dev_err(dev, "failed to create hcd\n");
 		retval = -ENOMEM;
 		goto fail_create_hcd;
 	}
-- 
2.30.2


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

* Re: [PATCH] usb: fotg210-hcd: Fix an error message
  2021-05-06 20:39 [PATCH] usb: fotg210-hcd: Fix an error message Christophe JAILLET
@ 2021-05-07  2:20 ` Chunfeng Yun
  2021-05-07  7:06   ` Christophe JAILLET
  2021-05-07  7:08   ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Chunfeng Yun @ 2021-05-07  2:20 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: gregkh, shubhankarvk, lee.jones, gustavoars, vulab, john453,
	linux-usb, linux-kernel, kernel-janitors

On Thu, 2021-05-06 at 22:39 +0200, Christophe JAILLET wrote:
> 'retval' is known to be -ENODEV here.
> This is a hard-coded default error code which is not useful in the error
> message. Moreover, another error message is printed at the end of the
> error handling path. The corresponding error code (-ENOMEM) is more
> informative.
> 
> So remove simplify the first error message.
> 
> While at it, also remove the useless initialization of 'retval'.
> 
> Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/usb/host/fotg210-hcd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
> index 6cac642520fc..9c2eda0918e1 100644
> --- a/drivers/usb/host/fotg210-hcd.c
> +++ b/drivers/usb/host/fotg210-hcd.c
> @@ -5568,7 +5568,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
>  	struct usb_hcd *hcd;
>  	struct resource *res;
>  	int irq;
> -	int retval = -ENODEV;
> +	int retval;
>  	struct fotg210_hcd *fotg210;
>  
>  	if (usb_disabled())
> @@ -5588,7 +5588,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
>  	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
>  			dev_name(dev));
>  	if (!hcd) {
> -		dev_err(dev, "failed to create hcd with err %d\n", retval);
> +		dev_err(dev, "failed to create hcd\n");
>  		retval = -ENOMEM;
How about moving this line before dev_err()? then could keep error log
unchanged.

>  		goto fail_create_hcd;
>  	}


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

* Re: [PATCH] usb: fotg210-hcd: Fix an error message
  2021-05-07  2:20 ` Chunfeng Yun
@ 2021-05-07  7:06   ` Christophe JAILLET
  2021-05-08  1:26     ` Chunfeng Yun
  2021-05-07  7:08   ` Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2021-05-07  7:06 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: gregkh, shubhankarvk, lee.jones, gustavoars, vulab, john453,
	linux-usb, linux-kernel, kernel-janitors

Le 07/05/2021 à 04:20, Chunfeng Yun a écrit :
> On Thu, 2021-05-06 at 22:39 +0200, Christophe JAILLET wrote:
>> 'retval' is known to be -ENODEV here.
>> This is a hard-coded default error code which is not useful in the error
>> message. Moreover, another error message is printed at the end of the
>> error handling path. The corresponding error code (-ENOMEM) is more
>> informative.
>>
>> So remove simplify the first error message.
>>
>> While at it, also remove the useless initialization of 'retval'.
>>
>> Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/usb/host/fotg210-hcd.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
>> index 6cac642520fc..9c2eda0918e1 100644
>> --- a/drivers/usb/host/fotg210-hcd.c
>> +++ b/drivers/usb/host/fotg210-hcd.c
>> @@ -5568,7 +5568,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
>>   	struct usb_hcd *hcd;
>>   	struct resource *res;
>>   	int irq;
>> -	int retval = -ENODEV;
>> +	int retval;
>>   	struct fotg210_hcd *fotg210;
>>   
>>   	if (usb_disabled())
>> @@ -5588,7 +5588,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
>>   	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
>>   			dev_name(dev));
>>   	if (!hcd) {
>> -		dev_err(dev, "failed to create hcd with err %d\n", retval);
>> +		dev_err(dev, "failed to create hcd\n");
>>   		retval = -ENOMEM;
> How about moving this line before dev_err()? then could keep error log
> unchanged.
> 

Mostly a matter of taste.
I don't think it add any useful information (this is not something 
coming from a call chain or that can have different values, it is just a 
hard-coded constant) and the line after we will already have:
	dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
where retval = -ENOMEM

So the -ENOMEM error code is already reported.

Moreover, having error code reported or not is already not consistent in 
the function. For example "failed to enable PCLK\n" where 'retval' could 
be reported as well.



BTW, is it useful to have 'dev_name(dev)' in a dev_err?

CJ

>>   		goto fail_create_hcd;
>>   	}
> 


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

* Re: [PATCH] usb: fotg210-hcd: Fix an error message
  2021-05-07  2:20 ` Chunfeng Yun
  2021-05-07  7:06   ` Christophe JAILLET
@ 2021-05-07  7:08   ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-05-07  7:08 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Christophe JAILLET, gregkh, shubhankarvk, lee.jones, gustavoars,
	vulab, john453, linux-usb, linux-kernel, kernel-janitors

On Fri, May 07, 2021 at 10:20:30AM +0800, Chunfeng Yun wrote:
> On Thu, 2021-05-06 at 22:39 +0200, Christophe JAILLET wrote:
> > 'retval' is known to be -ENODEV here.
> > This is a hard-coded default error code which is not useful in the error
> > message. Moreover, another error message is printed at the end of the
> > error handling path. The corresponding error code (-ENOMEM) is more
> > informative.
> > 
> > So remove simplify the first error message.
> > 
> > While at it, also remove the useless initialization of 'retval'.
> > 
> > Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> >  drivers/usb/host/fotg210-hcd.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
> > index 6cac642520fc..9c2eda0918e1 100644
> > --- a/drivers/usb/host/fotg210-hcd.c
> > +++ b/drivers/usb/host/fotg210-hcd.c
> > @@ -5568,7 +5568,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
> >  	struct usb_hcd *hcd;
> >  	struct resource *res;
> >  	int irq;
> > -	int retval = -ENODEV;
> > +	int retval;
> >  	struct fotg210_hcd *fotg210;
> >  
> >  	if (usb_disabled())
> > @@ -5588,7 +5588,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
> >  	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
> >  			dev_name(dev));
> >  	if (!hcd) {
> > -		dev_err(dev, "failed to create hcd with err %d\n", retval);
> > +		dev_err(dev, "failed to create hcd\n");
> >  		retval = -ENOMEM;
> How about moving this line before dev_err()? then could keep error log
> unchanged.

Then the error message would print misleading information.  The
usb_create_hcd() does not return -ENOMEM, it returns NULL.

regards,
dan carpenter


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

* Re: [PATCH] usb: fotg210-hcd: Fix an error message
  2021-05-07  7:06   ` Christophe JAILLET
@ 2021-05-08  1:26     ` Chunfeng Yun
  0 siblings, 0 replies; 5+ messages in thread
From: Chunfeng Yun @ 2021-05-08  1:26 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: gregkh, shubhankarvk, lee.jones, gustavoars, vulab, john453,
	linux-usb, linux-kernel, kernel-janitors

On Fri, 2021-05-07 at 09:06 +0200, Christophe JAILLET wrote:
> Le 07/05/2021 à 04:20, Chunfeng Yun a écrit :
> > On Thu, 2021-05-06 at 22:39 +0200, Christophe JAILLET wrote:
> >> 'retval' is known to be -ENODEV here.
> >> This is a hard-coded default error code which is not useful in the error
> >> message. Moreover, another error message is printed at the end of the
> >> error handling path. The corresponding error code (-ENOMEM) is more
> >> informative.
> >>
> >> So remove simplify the first error message.
> >>
> >> While at it, also remove the useless initialization of 'retval'.
> >>
> >> Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >> ---
> >>   drivers/usb/host/fotg210-hcd.c | 4 ++--
> >>   1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
> >> index 6cac642520fc..9c2eda0918e1 100644
> >> --- a/drivers/usb/host/fotg210-hcd.c
> >> +++ b/drivers/usb/host/fotg210-hcd.c
> >> @@ -5568,7 +5568,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
> >>   	struct usb_hcd *hcd;
> >>   	struct resource *res;
> >>   	int irq;
> >> -	int retval = -ENODEV;
> >> +	int retval;
> >>   	struct fotg210_hcd *fotg210;
> >>   
> >>   	if (usb_disabled())
> >> @@ -5588,7 +5588,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
> >>   	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
> >>   			dev_name(dev));
> >>   	if (!hcd) {
> >> -		dev_err(dev, "failed to create hcd with err %d\n", retval);
> >> +		dev_err(dev, "failed to create hcd\n");
> >>   		retval = -ENOMEM;
> > How about moving this line before dev_err()? then could keep error log
> > unchanged.
> > 
> 
> Mostly a matter of taste.
> I don't think it add any useful information (this is not something 
> coming from a call chain or that can have different values, it is just a 
> hard-coded constant) and the line after we will already have:
> 	dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
> where retval = -ENOMEM
> 
> So the -ENOMEM error code is already reported.
Yes

> 
> Moreover, having error code reported or not is already not consistent in 
> the function. For example "failed to enable PCLK\n" where 'retval' could 
> be reported as well.
> 
> 
> 
> BTW, is it useful to have 'dev_name(dev)' in a dev_err?
dev_err(dev, ...) itself will print it.

> 
> CJ
> 
> >>   		goto fail_create_hcd;
> >>   	}
> > 
> 


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

end of thread, other threads:[~2021-05-08  1:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 20:39 [PATCH] usb: fotg210-hcd: Fix an error message Christophe JAILLET
2021-05-07  2:20 ` Chunfeng Yun
2021-05-07  7:06   ` Christophe JAILLET
2021-05-08  1:26     ` Chunfeng Yun
2021-05-07  7:08   ` Dan Carpenter

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.