Linux USB
 help / color / mirror / Atom feed
* [PATCH v1] usb: gadget: udc: cdns2: Simplify with dev_err_probe()
@ 2024-08-29 11:28 Yan Zhen
  2024-08-29 17:04 ` Christophe JAILLET
  0 siblings, 1 reply; 2+ messages in thread
From: Yan Zhen @ 2024-08-29 11:28 UTC (permalink / raw)
  To: pawell, gregkh; +Cc: linux-usb, linux-kernel, opensource.kernel, Yan Zhen

Use dev_err_probe() to simplify the error path and unify a 
message template.

Using this helper is totally fine even if err is known to never 
be -EPROBE_DEFER.

The benefit compared to a normal dev_err() is the standardized format
of the error code, it being emitted symbolically and the fact that
the error code is returned which allows more compact error paths.

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
 drivers/usb/gadget/udc/cdns2/cdns2-pci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-pci.c b/drivers/usb/gadget/udc/cdns2/cdns2-pci.c
index 50c3d0974d9b..0e904085d968 100644
--- a/drivers/usb/gadget/udc/cdns2/cdns2-pci.c
+++ b/drivers/usb/gadget/udc/cdns2/cdns2-pci.c
@@ -35,10 +35,8 @@ static int cdns2_pci_probe(struct pci_dev *pdev,
 		return -EINVAL;
 
 	ret = pcim_enable_device(pdev);
-	if (ret) {
-		dev_err(&pdev->dev, "Enabling PCI device has failed %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Enabling PCI device has failed\n");
 
 	pci_set_master(pdev);
 
-- 
2.34.1


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

* Re: [PATCH v1] usb: gadget: udc: cdns2: Simplify with dev_err_probe()
  2024-08-29 11:28 [PATCH v1] usb: gadget: udc: cdns2: Simplify with dev_err_probe() Yan Zhen
@ 2024-08-29 17:04 ` Christophe JAILLET
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2024-08-29 17:04 UTC (permalink / raw)
  To: yanzhen@vivo.com >> Yan Zhen
  Cc: gregkh, linux-kernel, linux-usb, opensource.kernel, pawell

Le 29/08/2024 à 13:28, Yan Zhen a écrit :
> Use dev_err_probe() to simplify the error path and unify a
> message template.
> 
> Using this helper is totally fine even if err is known to never
> be -EPROBE_DEFER.
> 
> The benefit compared to a normal dev_err() is the standardized format
> of the error code, it being emitted symbolically and the fact that
> the error code is returned which allows more compact error paths.
> 
> Signed-off-by: Yan Zhen <yanzhen-DGpbCiVdSXo@public.gmane.org>
> ---
>   drivers/usb/gadget/udc/cdns2/cdns2-pci.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-pci.c b/drivers/usb/gadget/udc/cdns2/cdns2-pci.c
> index 50c3d0974d9b..0e904085d968 100644
> --- a/drivers/usb/gadget/udc/cdns2/cdns2-pci.c
> +++ b/drivers/usb/gadget/udc/cdns2/cdns2-pci.c
> @@ -35,10 +35,8 @@ static int cdns2_pci_probe(struct pci_dev *pdev,
>   		return -EINVAL;
>   
>   	ret = pcim_enable_device(pdev);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Enabling PCI device has failed %d\n", ret);
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret, "Enabling PCI device has failed\n");

Nitpick: 'dev' could also be used to be slightly less verbose (other 
opportunities exist in cdns2_pci_probe()).

CJ

>   
>   	pci_set_master(pdev);
>   


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

end of thread, other threads:[~2024-08-29 17:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29 11:28 [PATCH v1] usb: gadget: udc: cdns2: Simplify with dev_err_probe() Yan Zhen
2024-08-29 17:04 ` Christophe JAILLET

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