diff mbox series

hwrng: imx-rngc - use dev_err_probe

Message ID 20230704170644.69669-1-martin@kaiser.cx
State Accepted
Commit ea6084559285f4436434630a0e0d9e82709a04f2
Headers show
Series hwrng: imx-rngc - use dev_err_probe | expand

Commit Message

Martin Kaiser July 4, 2023, 5:06 p.m. UTC
Simplify the code by calling dev_err_probe instead of dev_err and return.

While at it, use the same device for all error messages.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/char/hw_random/imx-rngc.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

Comments

Rouven Czerwinski July 5, 2023, 5:14 a.m. UTC | #1
On Tue,  4 Jul 2023 19:06:44 +0200
Martin Kaiser <martin@kaiser.cx> wrote:

> Simplify the code by calling dev_err_probe instead of dev_err and
> return.
> 
> While at it, use the same device for all error messages.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>

Reviewed-by: Rouven Czerwinski <r.czerwinskis@pengutronix.de>

> ---
>  drivers/char/hw_random/imx-rngc.c | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/char/hw_random/imx-rngc.c
> b/drivers/char/hw_random/imx-rngc.c index bf07f17f78c8..e4b385b01b11
> 100644 --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -239,10 +239,8 @@ static int __init imx_rngc_probe(struct
> platform_device *pdev) return PTR_ERR(rngc->base);
>  
>  	rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> -	if (IS_ERR(rngc->clk)) {
> -		dev_err(&pdev->dev, "Can not get rng_clk\n");
> -		return PTR_ERR(rngc->clk);
> -	}
> +	if (IS_ERR(rngc->clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(rngc->clk),
> "Cannot get rng_clk\n"); 
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
> @@ -272,24 +270,18 @@ static int __init imx_rngc_probe(struct
> platform_device *pdev) 
>  	ret = devm_request_irq(&pdev->dev,
>  			irq, imx_rngc_irq, 0, pdev->name, (void
> *)rngc);
> -	if (ret) {
> -		dev_err(rngc->dev, "Can't get interrupt working.\n");
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret, "Can't get
> interrupt working.\n"); 
>  	if (self_test) {
>  		ret = imx_rngc_self_test(rngc);
> -		if (ret) {
> -			dev_err(rngc->dev, "self test failed\n");
> -			return ret;
> -		}
> +		if (ret)
> +			return dev_err_probe(&pdev->dev, ret, "self
> test failed\n"); }
>  
>  	ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
> -	if (ret) {
> -		dev_err(&pdev->dev, "hwrng registration failed\n");
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret, "hwrng
> registration failed\n"); 
>  	dev_info(&pdev->dev,
>  		"Freescale RNG%c registered (HW revision %d.%02d)\n",
Rouven Czerwinski July 5, 2023, 5:21 a.m. UTC | #2
Hi,

On Wed, 5 Jul 2023 07:14:31 +0200
Rouven Czerwinski <rcz@pengutronix.de> wrote:

> On Tue,  4 Jul 2023 19:06:44 +0200
> Martin Kaiser <martin@kaiser.cx> wrote:
> 
> > Simplify the code by calling dev_err_probe instead of dev_err and
> > return.
> > 
> > While at it, use the same device for all error messages.
> > 
> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>  
> 
> Reviewed-by: Rouven Czerwinski <r.czerwinskis@pengutronix.de>

Please disregard the first tag, the correct one should be

Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>

(note the missing s), I also fixed the mail address for this new mailer.

Sorry for the noise, shouldn't review before the first tea.

Best regards,

Rouven

> 
> > ---
> >  drivers/char/hw_random/imx-rngc.c | 24 ++++++++----------------
> >  1 file changed, 8 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/char/hw_random/imx-rngc.c
> > b/drivers/char/hw_random/imx-rngc.c index bf07f17f78c8..e4b385b01b11
> > 100644 --- a/drivers/char/hw_random/imx-rngc.c
> > +++ b/drivers/char/hw_random/imx-rngc.c
> > @@ -239,10 +239,8 @@ static int __init imx_rngc_probe(struct
> > platform_device *pdev) return PTR_ERR(rngc->base);
> >  
> >  	rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> > -	if (IS_ERR(rngc->clk)) {
> > -		dev_err(&pdev->dev, "Can not get rng_clk\n");
> > -		return PTR_ERR(rngc->clk);
> > -	}
> > +	if (IS_ERR(rngc->clk))
> > +		return dev_err_probe(&pdev->dev,
> > PTR_ERR(rngc->clk), "Cannot get rng_clk\n"); 
> >  	irq = platform_get_irq(pdev, 0);
> >  	if (irq < 0)
> > @@ -272,24 +270,18 @@ static int __init imx_rngc_probe(struct
> > platform_device *pdev) 
> >  	ret = devm_request_irq(&pdev->dev,
> >  			irq, imx_rngc_irq, 0, pdev->name, (void
> > *)rngc);
> > -	if (ret) {
> > -		dev_err(rngc->dev, "Can't get interrupt
> > working.\n");
> > -		return ret;
> > -	}
> > +	if (ret)
> > +		return dev_err_probe(&pdev->dev, ret, "Can't get
> > interrupt working.\n"); 
> >  	if (self_test) {
> >  		ret = imx_rngc_self_test(rngc);
> > -		if (ret) {
> > -			dev_err(rngc->dev, "self test failed\n");
> > -			return ret;
> > -		}
> > +		if (ret)
> > +			return dev_err_probe(&pdev->dev, ret, "self
> > test failed\n"); }
> >  
> >  	ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
> > -	if (ret) {
> > -		dev_err(&pdev->dev, "hwrng registration failed\n");
> > -		return ret;
> > -	}
> > +	if (ret)
> > +		return dev_err_probe(&pdev->dev, ret, "hwrng
> > registration failed\n"); 
> >  	dev_info(&pdev->dev,
> >  		"Freescale RNG%c registered (HW revision
> > %d.%02d)\n",  
> 
>
Herbert Xu July 14, 2023, 8:58 a.m. UTC | #3
On Tue, Jul 04, 2023 at 07:06:44PM +0200, Martin Kaiser wrote:
> Simplify the code by calling dev_err_probe instead of dev_err and return.
> 
> While at it, use the same device for all error messages.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>  drivers/char/hw_random/imx-rngc.c | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index bf07f17f78c8..e4b385b01b11 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -239,10 +239,8 @@  static int __init imx_rngc_probe(struct platform_device *pdev)
 		return PTR_ERR(rngc->base);
 
 	rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
-	if (IS_ERR(rngc->clk)) {
-		dev_err(&pdev->dev, "Can not get rng_clk\n");
-		return PTR_ERR(rngc->clk);
-	}
+	if (IS_ERR(rngc->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(rngc->clk), "Cannot get rng_clk\n");
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
@@ -272,24 +270,18 @@  static int __init imx_rngc_probe(struct platform_device *pdev)
 
 	ret = devm_request_irq(&pdev->dev,
 			irq, imx_rngc_irq, 0, pdev->name, (void *)rngc);
-	if (ret) {
-		dev_err(rngc->dev, "Can't get interrupt working.\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Can't get interrupt working.\n");
 
 	if (self_test) {
 		ret = imx_rngc_self_test(rngc);
-		if (ret) {
-			dev_err(rngc->dev, "self test failed\n");
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret, "self test failed\n");
 	}
 
 	ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
-	if (ret) {
-		dev_err(&pdev->dev, "hwrng registration failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "hwrng registration failed\n");
 
 	dev_info(&pdev->dev,
 		"Freescale RNG%c registered (HW revision %d.%02d)\n",