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,
	Michael Hennerich <michael.hennerich@analog.com>
Subject: Re: [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs
Date: Sat, 27 Jul 2013 12:26:37 +0100	[thread overview]
Message-ID: <51F3AE6D.2070205@kernel.org> (raw)
In-Reply-To: <1374490981-24373-5-git-send-email-sachin.kamat@linaro.org>

On 07/22/13 12:02, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
> This also takes care of missing clk_put function calls implicitly.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Michael Hennerich <michael.hennerich@analog.com>

Nice cleanup.

Applied to togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/iio/frequency/adf4350.c |   31 +++++++++----------------------
>  1 file changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
> index a4157cd..a7b30be 100644
> --- a/drivers/iio/frequency/adf4350.c
> +++ b/drivers/iio/frequency/adf4350.c
> @@ -515,7 +515,7 @@ static int adf4350_probe(struct spi_device *spi)
>  	}
>  
>  	if (!pdata->clkin) {
> -		clk = clk_get(&spi->dev, "clkin");
> +		clk = devm_clk_get(&spi->dev, "clkin");
>  		if (IS_ERR(clk))
>  			return -EPROBE_DEFER;
>  
> @@ -524,17 +524,17 @@ static int adf4350_probe(struct spi_device *spi)
>  			return ret;
>  	}
>  
> -	indio_dev = iio_device_alloc(sizeof(*st));
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
>  	if (indio_dev == NULL)
>  		return -ENOMEM;
>  
>  	st = iio_priv(indio_dev);
>  
> -	st->reg = regulator_get(&spi->dev, "vcc");
> +	st->reg = devm_regulator_get(&spi->dev, "vcc");
>  	if (!IS_ERR(st->reg)) {
>  		ret = regulator_enable(st->reg);
>  		if (ret)
> -			goto error_put_reg;
> +			goto error_disable_clk;
>  	}
>  
>  	spi_set_drvdata(spi, indio_dev);
> @@ -564,7 +564,8 @@ static int adf4350_probe(struct spi_device *spi)
>  	memset(st->regs_hw, 0xFF, sizeof(st->regs_hw));
>  
>  	if (gpio_is_valid(pdata->gpio_lock_detect)) {
> -		ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name);
> +		ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect,
> +					indio_dev->name);
>  		if (ret) {
>  			dev_err(&spi->dev, "fail to request lock detect GPIO-%d",
>  				pdata->gpio_lock_detect);
> @@ -576,29 +577,21 @@ static int adf4350_probe(struct spi_device *spi)
>  	if (pdata->power_up_frequency) {
>  		ret = adf4350_set_freq(st, pdata->power_up_frequency);
>  		if (ret)
> -			goto error_free_gpio;
> +			goto error_disable_reg;
>  	}
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
> -		goto error_free_gpio;
> +		goto error_disable_reg;
>  
>  	return 0;
>  
> -error_free_gpio:
> -	if (gpio_is_valid(pdata->gpio_lock_detect))
> -		gpio_free(pdata->gpio_lock_detect);
> -
>  error_disable_reg:
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> -error_put_reg:
> -	if (!IS_ERR(st->reg))
> -		regulator_put(st->reg);
> -
> +error_disable_clk:
>  	if (clk)
>  		clk_disable_unprepare(clk);
> -	iio_device_free(indio_dev);
>  
>  	return ret;
>  }
> @@ -619,14 +612,8 @@ static int adf4350_remove(struct spi_device *spi)
>  
>  	if (!IS_ERR(reg)) {
>  		regulator_disable(reg);
> -		regulator_put(reg);
>  	}
>  
> -	if (gpio_is_valid(st->pdata->gpio_lock_detect))
> -		gpio_free(st->pdata->gpio_lock_detect);
> -
> -	iio_device_free(indio_dev);
> -
>  	return 0;
>  }
>  
> 

  reply	other threads:[~2013-07-27 10:26 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 [this message]
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
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=51F3AE6D.2070205@kernel.org \
    --to=jic23@kernel.org \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=patches@linaro.org \
    --cc=sachin.kamat@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.