Re: [PATCH -next v2 2/2] iio: adc: spear_adc: Use dev_err_probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 26 Aug 2023 14:27:32 +0800
Jinjie Ruan <ruanjinjie@xxxxxxxxxx> wrote:

> Use the dev_err_probe() helper to simplify error handling during probe.
> This also handle scenario, when EDEFER is returned and useless error
> is printed.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
> ---
>  drivers/iio/adc/spear_adc.c | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
> index d24adacfdf53..0ccda1cd0add 100644
> --- a/drivers/iio/adc/spear_adc.c
> +++ b/drivers/iio/adc/spear_adc.c
> @@ -274,10 +274,8 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	int irq;
>  
>  	indio_dev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state));
> -	if (!indio_dev) {
> -		dev_err(dev, "failed allocating iio device\n");
> -		return -ENOMEM;
> -	}
> +	if (!indio_dev)
> +		return dev_err_probe(dev, -ENOMEM, "failed allocating iio device\n");

Whilst 100 chars tends to be allowed if it helps readability, in cases
like this one, where it makes very little difference to how easy the code is
to read, keep to max 80 chars.

I've added some line breaks whilst applying.

Series applied to the togreg branch of iio.git and pushed out as testing.
I'll be rebasing on rc1 once available so I won't push this out for linux-next
to pick up until I've done that in a few weeks time.

Nice cleanup.

Thanks,

Jonathan

>  
>  	st = iio_priv(indio_dev);
>  
> @@ -298,10 +296,8 @@ static int spear_adc_probe(struct platform_device *pdev)
>  		(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
>  
>  	st->clk = devm_clk_get_enabled(dev, NULL);
> -	if (IS_ERR(st->clk)) {
> -		dev_err(dev, "failed enabling clock\n");
> -		return PTR_ERR(st->clk);
> -	}
> +	if (IS_ERR(st->clk))
> +		return dev_err_probe(dev, PTR_ERR(st->clk), "failed enabling clock\n");
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
> @@ -309,16 +305,12 @@ static int spear_adc_probe(struct platform_device *pdev)
>  
>  	ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME,
>  			       st);
> -	if (ret < 0) {
> -		dev_err(dev, "failed requesting interrupt\n");
> -		return ret;
> -	}
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "failed requesting interrupt\n");
>  
>  	if (of_property_read_u32(np, "sampling-frequency",
> -				 &st->sampling_freq)) {
> -		dev_err(dev, "sampling-frequency missing in DT\n");
> -		return -EINVAL;
> -	}
> +				 &st->sampling_freq))
> +		return dev_err_probe(dev, -EINVAL, "sampling-frequency missing in DT\n");
>  
>  	/*
>  	 * Optional avg_samples defaults to 0, resulting in single data




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux