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: jic23@kernel.org, lars@metafoo.de, sachin.kamat@linaro.org
Subject: [PATCH 7/9] staging: iio: ad799x_core: Use devm_* APIs
Date: Sat, 31 Aug 2013 22:42:37 +0530	[thread overview]
Message-ID: <1377969159-2491-7-git-send-email-sachin.kamat@linaro.org> (raw)
In-Reply-To: <1377969159-2491-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/staging/iio/adc/ad799x_core.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 2b2049c..3f5142b 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -586,8 +586,9 @@ static int ad799x_probe(struct i2c_client *client,
 	int ret;
 	struct ad799x_platform_data *pdata = client->dev.platform_data;
 	struct ad799x_state *st;
-	struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
+	struct iio_dev *indio_dev;
 
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
 	if (indio_dev == NULL)
 		return -ENOMEM;
 
@@ -606,11 +607,11 @@ static int ad799x_probe(struct i2c_client *client,
 
 	st->int_vref_mv = pdata->vref_mv;
 
-	st->reg = regulator_get(&client->dev, "vcc");
+	st->reg = devm_regulator_get(&client->dev, "vcc");
 	if (!IS_ERR(st->reg)) {
 		ret = regulator_enable(st->reg);
 		if (ret)
-			goto error_put_reg;
+			return ret;
 	}
 	st->client = client;
 
@@ -650,10 +651,6 @@ error_cleanup_ring:
 error_disable_reg:
 	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-error_put_reg:
-	if (!IS_ERR(st->reg))
-		regulator_put(st->reg);
-	iio_device_free(indio_dev);
 
 	return ret;
 }
@@ -668,12 +665,9 @@ static int ad799x_remove(struct i2c_client *client)
 		free_irq(client->irq, indio_dev);
 
 	ad799x_ring_cleanup(indio_dev);
-	if (!IS_ERR(st->reg)) {
+	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-		regulator_put(st->reg);
-	}
 	kfree(st->rx_buf);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.4.1


  parent reply	other threads:[~2013-08-31 17:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-31 17:12 [PATCH 1/9] staging: iio: ad7192: Use devm_* APIs Sachin Kamat
2013-08-31 17:12 ` [PATCH 2/9] staging: iio: ad7280a: Use devm_iio_device_alloc Sachin Kamat
2013-08-31 17:12 ` [PATCH 3/9] staging: iio: ad7291: Use devm_* APIs Sachin Kamat
2013-08-31 17:12 ` [PATCH 4/9] staging: iio: ad7606_core: " Sachin Kamat
2013-08-31 17:12 ` [PATCH 5/9] staging: iio: ad7780: " Sachin Kamat
2013-08-31 17:12 ` [PATCH 6/9] staging: iio: ad7816: " Sachin Kamat
2013-08-31 17:12 ` Sachin Kamat [this message]
2013-08-31 17:12 ` [PATCH 8/9] staging: iio: lpc32xx_adc: " Sachin Kamat
2013-08-31 17:12 ` [PATCH 9/9] staging: iio: adt7316: " Sachin Kamat
2013-08-31 18:31 ` [PATCH 1/9] staging: iio: ad7192: " Jonathan Cameron
2013-09-01  5:51   ` Sachin Kamat
2013-09-07 20:51     ` 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=1377969159-2491-7-git-send-email-sachin.kamat@linaro.org \
    --to=sachin.kamat@linaro.org \
    --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).