All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Sachin Kamat <sachin.kamat@linaro.org>
Cc: linux-iio@vger.kernel.org, jic23@cam.ac.uk, patches@linaro.org,
	Stefan Roese <sr@denx.de>, Viresh Kumar <viresh.kumar@linaro.org>
Subject: Re: [PATCH 6/8] staging: iio: spear_adc: Use devm_iio_device_alloc
Date: Sat, 27 Jul 2013 12:29:44 +0100	[thread overview]
Message-ID: <51F3AF28.6080706@kernel.org> (raw)
In-Reply-To: <1374490981-24373-7-git-send-email-sachin.kamat@linaro.org>

On 07/22/13 12:02, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
Applied to the togreg branch of iio.git.

Thanks
> ---
>  drivers/staging/iio/adc/spear_adc.c |   30 ++++++++++++------------------
>  1 file changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
> index 736219c..20f2d55 100644
> --- a/drivers/staging/iio/adc/spear_adc.c
> +++ b/drivers/staging/iio/adc/spear_adc.c
> @@ -300,11 +300,10 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	int ret = -ENODEV;
>  	int irq;
>  
> -	iodev = iio_device_alloc(sizeof(struct spear_adc_info));
> +	iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info));
>  	if (!iodev) {
>  		dev_err(dev, "failed allocating iio device\n");
> -		ret = -ENOMEM;
> -		goto errout1;
> +		return -ENOMEM;
>  	}
>  
>  	info = iio_priv(iodev);
> @@ -318,8 +317,7 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	info->adc_base_spear6xx = of_iomap(np, 0);
>  	if (!info->adc_base_spear6xx) {
>  		dev_err(dev, "failed mapping memory\n");
> -		ret = -ENOMEM;
> -		goto errout2;
> +		return -ENOMEM;
>  	}
>  	info->adc_base_spear3xx =
>  		(struct adc_regs_spear3xx *)info->adc_base_spear6xx;
> @@ -327,33 +325,33 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	info->clk = clk_get(dev, NULL);
>  	if (IS_ERR(info->clk)) {
>  		dev_err(dev, "failed getting clock\n");
> -		goto errout3;
> +		goto errout1;
>  	}
>  
>  	ret = clk_prepare_enable(info->clk);
>  	if (ret) {
>  		dev_err(dev, "failed enabling clock\n");
> -		goto errout4;
> +		goto errout2;
>  	}
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if ((irq < 0) || (irq >= NR_IRQS)) {
>  		dev_err(dev, "failed getting interrupt resource\n");
>  		ret = -EINVAL;
> -		goto errout5;
> +		goto errout3;
>  	}
>  
>  	ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
>  	if (ret < 0) {
>  		dev_err(dev, "failed requesting interrupt\n");
> -		goto errout5;
> +		goto errout3;
>  	}
>  
>  	if (of_property_read_u32(np, "sampling-frequency",
>  				 &info->sampling_freq)) {
>  		dev_err(dev, "sampling-frequency missing in DT\n");
>  		ret = -EINVAL;
> -		goto errout5;
> +		goto errout3;
>  	}
>  
>  	/*
> @@ -383,21 +381,18 @@ static int spear_adc_probe(struct platform_device *pdev)
>  
>  	ret = iio_device_register(iodev);
>  	if (ret)
> -		goto errout5;
> +		goto errout3;
>  
>  	dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
>  
>  	return 0;
>  
> -errout5:
> -	clk_disable_unprepare(info->clk);
> -errout4:
> -	clk_put(info->clk);
>  errout3:
> -	iounmap(info->adc_base_spear6xx);
> +	clk_disable_unprepare(info->clk);
>  errout2:
> -	iio_device_free(iodev);
> +	clk_put(info->clk);
>  errout1:
> +	iounmap(info->adc_base_spear6xx);
>  	return ret;
>  }
>  
> @@ -410,7 +405,6 @@ static int spear_adc_remove(struct platform_device *pdev)
>  	clk_disable_unprepare(info->clk);
>  	clk_put(info->clk);
>  	iounmap(info->adc_base_spear6xx);
> -	iio_device_free(iodev);
>  
>  	return 0;
>  }
> 

  reply	other threads:[~2013-07-27 10:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
2013-07-22 11:02 ` [PATCH 1/8] iio: at91: " Sachin Kamat
2013-07-27 11:24   ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 2/8] iio: exynos_adc: " Sachin Kamat
2013-07-27 11:25   ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 3/8] iio: max1363: " Sachin Kamat
2013-07-27 11:25   ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs Sachin Kamat
2013-07-27 11:26   ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Sachin Kamat
2013-07-22 22:04   ` Marek Vasut
2013-07-27 11:29     ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 6/8] staging: iio: spear_adc: " Sachin Kamat
2013-07-27 11:29   ` Jonathan Cameron [this message]
2013-07-22 11:03 ` [PATCH 7/8] staging: iio: light: isl29018: " Sachin Kamat
2013-07-22 15:16   ` Rhyland Klein
2013-07-27 11:30     ` Jonathan Cameron
2013-07-22 11:03 ` [PATCH 8/8] staging: iio: light: isl29028: " Sachin Kamat
2013-07-27 11:31   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51F3AF28.6080706@kernel.org \
    --to=jic23@kernel.org \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=sachin.kamat@linaro.org \
    --cc=sr@denx.de \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.