linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Sachin Kamat <sachin.kamat@linaro.org>,
	linux-iio@vger.kernel.org, jic23@cam.ac.uk
Subject: Re: [PATCH 4/4] iio: adc: ad7266: Use devm_* APIs
Date: Sat, 27 Jul 2013 11:59:16 +0100	[thread overview]
Message-ID: <51F3A804.2000206@kernel.org> (raw)
In-Reply-To: <51EF8AE3.6040008@metafoo.de>

On 07/24/13 09:05, Lars-Peter Clausen wrote:
> On 07/23/2013 08:50 AM, Sachin Kamat wrote:
>> devm_* APIs are device managed and make code simpler.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> Cc: Lars-Peter Clausen <lars@metafoo.de>
> 
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks
> 
>> ---
>>  drivers/iio/adc/ad7266.c |   16 ++++------------
>>  1 file changed, 4 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
>> index c2744a7..371731d 100644
>> --- a/drivers/iio/adc/ad7266.c
>> +++ b/drivers/iio/adc/ad7266.c
>> @@ -399,17 +399,17 @@ static int ad7266_probe(struct spi_device *spi)
>>  	unsigned int i;
>>  	int 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, "vref");
>> +	st->reg = devm_regulator_get(&spi->dev, "vref");
>>  	if (!IS_ERR_OR_NULL(st->reg)) {
>>  		ret = regulator_enable(st->reg);
>>  		if (ret)
>> -			goto error_put_reg;
>> +			return ret;
>>  
>>  		ret = regulator_get_voltage(st->reg);
>>  		if (ret < 0)
>> @@ -489,11 +489,6 @@ error_free_gpios:
>>  error_disable_reg:
>>  	if (!IS_ERR_OR_NULL(st->reg))
>>  		regulator_disable(st->reg);
>> -error_put_reg:
>> -	if (!IS_ERR_OR_NULL(st->reg))
>> -		regulator_put(st->reg);
>> -
>> -	iio_device_free(indio_dev);
>>  
>>  	return ret;
>>  }
>> @@ -507,11 +502,8 @@ static int ad7266_remove(struct spi_device *spi)
>>  	iio_triggered_buffer_cleanup(indio_dev);
>>  	if (!st->fixed_addr)
>>  		gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios));
>> -	if (!IS_ERR_OR_NULL(st->reg)) {
>> +	if (!IS_ERR_OR_NULL(st->reg))
>>  		regulator_disable(st->reg);
>> -		regulator_put(st->reg);
>> -	}
>> -	iio_device_free(indio_dev);
>>  
>>  	return 0;
>>  }
>>
> 

      reply	other threads:[~2013-07-27  9:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23  6:50 [PATCH 4/4] iio: adc: ad7266: Use devm_* APIs Sachin Kamat
2013-07-24  8:05 ` Lars-Peter Clausen
2013-07-27 10:59   ` Jonathan Cameron [this message]

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=51F3A804.2000206@kernel.org \
    --to=jic23@kernel.org \
    --cc=jic23@cam.ac.uk \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).