diff mbox series

[1/2] irqchip/imx-intmux: Use dev_err_probe() to simplify error handling

Message ID 1597119905-7341-1-git-send-email-Anson.Huang@nxp.com (mailing list archive)
State New, archived
Headers show
Series [1/2] irqchip/imx-intmux: Use dev_err_probe() to simplify error handling | expand

Commit Message

Anson Huang Aug. 11, 2020, 4:25 a.m. UTC
dev_err_probe() can reduce code size, uniform error handling and record the
defer probe reason etc., use it to simplify the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Ahmad Fatoum Aug. 11, 2020, 5:46 a.m. UTC | #1
Hello,

On 8/11/20 6:25 AM, Anson Huang wrote:
> dev_err_probe() can reduce code size, uniform error handling and record the
> defer probe reason etc., use it to simplify the code.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
>  drivers/irqchip/irq-imx-intmux.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
> index e35b7b0..2f51ec9 100644
> --- a/drivers/irqchip/irq-imx-intmux.c
> +++ b/drivers/irqchip/irq-imx-intmux.c
> @@ -226,12 +226,10 @@ static int imx_intmux_probe(struct platform_device *pdev)
>  	}
>  
>  	data->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
> -	if (IS_ERR(data->ipg_clk)) {
> -		ret = PTR_ERR(data->ipg_clk);
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret);
> -		return ret;
> -	}
> +	if (IS_ERR(data->ipg_clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(data->ipg_clk),
> +				     "failed to get ipg clk: %ld\n",
> +				     PTR_ERR(data->ipg_clk));

Haven't used dev_err_probe myself yet, but the function does

	if (err != -EPROBE_DEFER) {
		dev_err(dev, "error %d: %pV", err, &vaf);

so your message would become

	"error %d: failed to get ipg clk: %d\n"

printing the same error code twice. If so, you should drop the second.

Cheers
Ahmad

>  
>  	data->channum = channum;
>  	raw_spin_lock_init(&data->lock);
>
Anson Huang Aug. 11, 2020, 6:02 a.m. UTC | #2
Hi, Ahmad


> Subject: Re: [PATCH 1/2] irqchip/imx-intmux: Use dev_err_probe() to simplify
> error handling
> 
> Hello,
> 
> On 8/11/20 6:25 AM, Anson Huang wrote:
> > dev_err_probe() can reduce code size, uniform error handling and
> > record the defer probe reason etc., use it to simplify the code.
> >
> > Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> > ---
> >  drivers/irqchip/irq-imx-intmux.c | 10 ++++------
> >  1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/irqchip/irq-imx-intmux.c
> > b/drivers/irqchip/irq-imx-intmux.c
> > index e35b7b0..2f51ec9 100644
> > --- a/drivers/irqchip/irq-imx-intmux.c
> > +++ b/drivers/irqchip/irq-imx-intmux.c
> > @@ -226,12 +226,10 @@ static int imx_intmux_probe(struct
> platform_device *pdev)
> >  	}
> >
> >  	data->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
> > -	if (IS_ERR(data->ipg_clk)) {
> > -		ret = PTR_ERR(data->ipg_clk);
> > -		if (ret != -EPROBE_DEFER)
> > -			dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret);
> > -		return ret;
> > -	}
> > +	if (IS_ERR(data->ipg_clk))
> > +		return dev_err_probe(&pdev->dev, PTR_ERR(data->ipg_clk),
> > +				     "failed to get ipg clk: %ld\n",
> > +				     PTR_ERR(data->ipg_clk));
> 
> Haven't used dev_err_probe myself yet, but the function does
> 
> 	if (err != -EPROBE_DEFER) {
> 		dev_err(dev, "error %d: %pV", err, &vaf);
> 
> so your message would become
> 
> 	"error %d: failed to get ipg clk: %d\n"
> 
> printing the same error code twice. If so, you should drop the second.

Correct, I will fix it in V2.

Thanks,
Anson
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index e35b7b0..2f51ec9 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -226,12 +226,10 @@  static int imx_intmux_probe(struct platform_device *pdev)
 	}
 
 	data->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
-	if (IS_ERR(data->ipg_clk)) {
-		ret = PTR_ERR(data->ipg_clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(data->ipg_clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(data->ipg_clk),
+				     "failed to get ipg clk: %ld\n",
+				     PTR_ERR(data->ipg_clk));
 
 	data->channum = channum;
 	raw_spin_lock_init(&data->lock);