diff mbox series

[v1,4/5] usb: fotg210: Switch to use dev_err_probe()

Message ID 20230120154437.22025-4-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,1/5] usb: fotg210-hcd: use sysfs_emit() to instead of scnprintf() | expand

Commit Message

Andy Shevchenko Jan. 20, 2023, 3:44 p.m. UTC
Switch to use dev_err_probe() to simplify the error paths and
unify message template.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/fotg210/fotg210-core.c | 6 ++----
 drivers/usb/fotg210/fotg210-hcd.c  | 8 +++-----
 drivers/usb/fotg210/fotg210-udc.c  | 2 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

Comments

Linus Walleij Jan. 26, 2023, 8:01 p.m. UTC | #1
On Fri, Jan 20, 2023 at 4:44 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Switch to use dev_err_probe() to simplify the error paths and
> unify message template.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Christophe JAILLET Feb. 16, 2023, 8:07 a.m. UTC | #2
Le 20/01/2023 à 16:44, Andy Shevchenko a écrit :
> Switch to use dev_err_probe() to simplify the error paths and
> unify message template.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>   drivers/usb/fotg210/fotg210-core.c | 6 ++----
>   drivers/usb/fotg210/fotg210-hcd.c  | 8 +++-----
>   drivers/usb/fotg210/fotg210-udc.c  | 2 +-
>   3 files changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg210-core.c
> index c06f8eb3acbd..ce00d9407ce5 100644
> --- a/drivers/usb/fotg210/fotg210-core.c
> +++ b/drivers/usb/fotg210/fotg210-core.c
> @@ -50,10 +50,8 @@ static int fotg210_gemini_init(struct fotg210 *fotg, struct resource *res,
>   	int ret;
>   
>   	map = syscon_regmap_lookup_by_phandle(np, "syscon");
> -	if (IS_ERR(map)) {
> -		dev_err(dev, "no syscon\n");
> -		return PTR_ERR(map);
> -	}
> +	if (IS_ERR(map))
> +		return dev_err_probe(dev, PTR_ERR(map), "no syscon\n");
>   	fotg->map = map;
>   	wakeup = of_property_read_bool(np, "wakeup-source");
>   
> diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c
> index 5a934f5343a7..613d29f04bcb 100644
> --- a/drivers/usb/fotg210/fotg210-hcd.c
> +++ b/drivers/usb/fotg210/fotg210-hcd.c
> @@ -5575,8 +5575,7 @@ int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
>   	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
>   			dev_name(dev));
>   	if (!hcd) {
> -		dev_err(dev, "failed to create hcd\n");
> -		retval = -ENOMEM;
> +		retval = dev_err_probe(dev, -ENOMEM, "failed to create hcd\n");
>   		goto fail_create_hcd;
>   	}
>   
> @@ -5600,7 +5599,7 @@ int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
>   
>   	retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
>   	if (retval) {
> -		dev_err(dev, "failed to add hcd with err %d\n", retval);
> +		dev_err_probe(dev, retval, "failed to add hcd\n");
>   		goto failed_put_hcd;
>   	}
>   	device_wakeup_enable(hcd->self.controller);
> @@ -5611,8 +5610,7 @@ int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
>   failed_put_hcd:
>   	usb_put_hcd(hcd);
>   fail_create_hcd:
> -	dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
> -	return retval;
> +	return dev_err_probe(dev, retval, "init %s fail\n", dev_name(dev));

Hi,
the patch is already applied, but is dev_name(dev) needed here?

CJ

>   }
>   
>   /*
> diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
> index 18d254125186..5b515f5cb2d7 100644
> --- a/drivers/usb/fotg210/fotg210-udc.c
> +++ b/drivers/usb/fotg210/fotg210-udc.c
> @@ -1258,7 +1258,7 @@ int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg)
>   	ret = request_irq(irq, fotg210_irq, IRQF_SHARED,
>   			  udc_name, fotg210);
>   	if (ret < 0) {
> -		dev_err(dev, "request_irq error (%d)\n", ret);
> +		dev_err_probe(dev, ret, "request_irq error\n");
>   		goto err_req;
>   	}
>
Linus Walleij Feb. 16, 2023, 8:30 a.m. UTC | #3
On Thu, Feb 16, 2023 at 9:07 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:

> > -     dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
> > -     return retval;
> > +     return dev_err_probe(dev, retval, "init %s fail\n", dev_name(dev));
>
> Hi,
> the patch is already applied, but is dev_name(dev) needed here?

Not really but it's not a big deal either, it's just a string.
Feel free to send an incremental patch dropping it :)

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg210-core.c
index c06f8eb3acbd..ce00d9407ce5 100644
--- a/drivers/usb/fotg210/fotg210-core.c
+++ b/drivers/usb/fotg210/fotg210-core.c
@@ -50,10 +50,8 @@  static int fotg210_gemini_init(struct fotg210 *fotg, struct resource *res,
 	int ret;
 
 	map = syscon_regmap_lookup_by_phandle(np, "syscon");
-	if (IS_ERR(map)) {
-		dev_err(dev, "no syscon\n");
-		return PTR_ERR(map);
-	}
+	if (IS_ERR(map))
+		return dev_err_probe(dev, PTR_ERR(map), "no syscon\n");
 	fotg->map = map;
 	wakeup = of_property_read_bool(np, "wakeup-source");
 
diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c
index 5a934f5343a7..613d29f04bcb 100644
--- a/drivers/usb/fotg210/fotg210-hcd.c
+++ b/drivers/usb/fotg210/fotg210-hcd.c
@@ -5575,8 +5575,7 @@  int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
 	hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
 			dev_name(dev));
 	if (!hcd) {
-		dev_err(dev, "failed to create hcd\n");
-		retval = -ENOMEM;
+		retval = dev_err_probe(dev, -ENOMEM, "failed to create hcd\n");
 		goto fail_create_hcd;
 	}
 
@@ -5600,7 +5599,7 @@  int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
 
 	retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (retval) {
-		dev_err(dev, "failed to add hcd with err %d\n", retval);
+		dev_err_probe(dev, retval, "failed to add hcd\n");
 		goto failed_put_hcd;
 	}
 	device_wakeup_enable(hcd->self.controller);
@@ -5611,8 +5610,7 @@  int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg)
 failed_put_hcd:
 	usb_put_hcd(hcd);
 fail_create_hcd:
-	dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
-	return retval;
+	return dev_err_probe(dev, retval, "init %s fail\n", dev_name(dev));
 }
 
 /*
diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
index 18d254125186..5b515f5cb2d7 100644
--- a/drivers/usb/fotg210/fotg210-udc.c
+++ b/drivers/usb/fotg210/fotg210-udc.c
@@ -1258,7 +1258,7 @@  int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg)
 	ret = request_irq(irq, fotg210_irq, IRQF_SHARED,
 			  udc_name, fotg210);
 	if (ret < 0) {
-		dev_err(dev, "request_irq error (%d)\n", ret);
+		dev_err_probe(dev, ret, "request_irq error\n");
 		goto err_req;
 	}