linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sachin Kamat <sachin.kamat@linaro.org>
To: linux-iio@vger.kernel.org
Cc: lars@metafoo.de, jic23@cam.ac.uk, jic23@kernel.org,
	sachin.kamat@linaro.org
Subject: [PATCH 03/14] iio: dac: ad5380: Use devm_* APIs
Date: Mon, 19 Aug 2013 17:08:14 +0530	[thread overview]
Message-ID: <1376912305-6423-3-git-send-email-sachin.kamat@linaro.org> (raw)
In-Reply-To: <1376912305-6423-1-git-send-email-sachin.kamat@linaro.org>

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/iio/dac/ad5380.c |   18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index bf2db02..1c44ae3 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -369,11 +369,10 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
 	unsigned int ctrl = 0;
 	int ret;
 
-	indio_dev = iio_device_alloc(sizeof(*st));
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
 	if (indio_dev == NULL) {
 		dev_err(dev, "Failed to allocate iio device\n");
-		ret = -ENOMEM;
-		goto error_out;
+		return -ENOMEM;
 	}
 
 	st = iio_priv(indio_dev);
@@ -391,13 +390,13 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
 	ret = ad5380_alloc_channels(indio_dev);
 	if (ret) {
 		dev_err(dev, "Failed to allocate channel spec: %d\n", ret);
-		goto error_free;
+		return ret;
 	}
 
 	if (st->chip_info->int_vref == 2500000)
 		ctrl |= AD5380_CTRL_INT_VREF_2V5;
 
-	st->vref_reg = regulator_get(dev, "vref");
+	st->vref_reg = devm_regulator_get(dev, "vref");
 	if (!IS_ERR(st->vref_reg)) {
 		ret = regulator_enable(st->vref_reg);
 		if (ret) {
@@ -434,13 +433,7 @@ error_disable_reg:
 	if (!IS_ERR(st->vref_reg))
 		regulator_disable(st->vref_reg);
 error_free_reg:
-	if (!IS_ERR(st->vref_reg))
-		regulator_put(st->vref_reg);
-
 	kfree(indio_dev->channels);
-error_free:
-	iio_device_free(indio_dev);
-error_out:
 
 	return ret;
 }
@@ -456,11 +449,8 @@ static int ad5380_remove(struct device *dev)
 
 	if (!IS_ERR(st->vref_reg)) {
 		regulator_disable(st->vref_reg);
-		regulator_put(st->vref_reg);
 	}
 
-	iio_device_free(indio_dev);
-
 	return 0;
 }
 
-- 
1.7.9.5

  parent reply	other threads:[~2013-08-19 11:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 11:38 [PATCH 01/14] iio: dac: ad5064: Use devm_* APIs Sachin Kamat
2013-08-19 11:38 ` [PATCH 02/14] iio: dac: ad5360: " Sachin Kamat
2013-08-19 19:23   ` Jonathan Cameron
2013-08-19 11:38 ` Sachin Kamat [this message]
2013-08-19 19:23   ` [PATCH 03/14] iio: dac: ad5380: " Jonathan Cameron
2013-08-19 11:38 ` [PATCH 04/14] iio: dac: ad5421: " Sachin Kamat
2013-08-19 19:24   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 05/14] iio: dac: ad5446: " Sachin Kamat
2013-08-19 19:25   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 06/14] iio: dac: ad5449: " Sachin Kamat
2013-08-19 19:26   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 07/14] iio: dac: ad5504: " Sachin Kamat
2013-08-19 19:27   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 08/14] iio: dac: ad5624r_spi: " Sachin Kamat
2013-08-19 19:28   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 09/14] iio: dac: ad5686: " Sachin Kamat
2013-08-19 19:30   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 10/14] iio: dac: ad5755: Use devm_iio_device_alloc Sachin Kamat
2013-08-19 19:33   ` Jonathan Cameron
2013-08-20 13:47     ` Sachin Kamat
2013-08-19 11:38 ` [PATCH 11/14] iio: dac: ad5764: Use devm_* APIs Sachin Kamat
2013-08-19 19:33   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 12/14] iio: dac: ad5791: " Sachin Kamat
2013-08-19 19:35   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 13/14] iio: dac: ad7303: " Sachin Kamat
2013-08-19 19:36   ` Jonathan Cameron
2013-08-19 11:38 ` [PATCH 14/14] iio: dac: max517: Use devm_iio_device_alloc Sachin Kamat
2013-08-19 19:38   ` Jonathan Cameron
2013-08-19 19:20 ` [PATCH 01/14] iio: dac: ad5064: Use devm_* APIs 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=1376912305-6423-3-git-send-email-sachin.kamat@linaro.org \
    --to=sachin.kamat@linaro.org \
    --cc=jic23@cam.ac.uk \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.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).