linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/14] iio: dac: ad5064: Use devm_* APIs
@ 2013-08-19 11:38 Sachin Kamat
  2013-08-19 11:38 ` [PATCH 02/14] iio: dac: ad5360: " Sachin Kamat
                   ` (13 more replies)
  0 siblings, 14 replies; 29+ messages in thread
From: Sachin Kamat @ 2013-08-19 11:38 UTC (permalink / raw)
  To: linux-iio; +Cc: lars, jic23, jic23, sachin.kamat

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
This series is compile tested and based on togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
---
 drivers/iio/dac/ad5064.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index aa26d50..a3a52be 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -442,7 +442,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
 	unsigned int i;
 	int ret;
 
-	indio_dev = iio_device_alloc(sizeof(*st));
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
 	if (indio_dev == NULL)
 		return  -ENOMEM;
 
@@ -456,23 +456,23 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
 	for (i = 0; i < ad5064_num_vref(st); ++i)
 		st->vref_reg[i].supply = ad5064_vref_name(st, i);
 
-	ret = regulator_bulk_get(dev, ad5064_num_vref(st),
+	ret = devm_regulator_bulk_get(dev, ad5064_num_vref(st),
 		st->vref_reg);
 	if (ret) {
 		if (!st->chip_info->internal_vref)
-			goto error_free;
+			return ret;
 		st->use_internal_vref = true;
 		ret = ad5064_write(st, AD5064_CMD_CONFIG, 0,
 			AD5064_CONFIG_INT_VREF_ENABLE, 0);
 		if (ret) {
 			dev_err(dev, "Failed to enable internal vref: %d\n",
 				ret);
-			goto error_free;
+			return ret;
 		}
 	} else {
 		ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg);
 		if (ret)
-			goto error_free_reg;
+			return ret;
 	}
 
 	indio_dev->dev.parent = dev;
@@ -498,11 +498,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
 error_disable_reg:
 	if (!st->use_internal_vref)
 		regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
-error_free_reg:
-	if (!st->use_internal_vref)
-		regulator_bulk_free(ad5064_num_vref(st), st->vref_reg);
-error_free:
-	iio_device_free(indio_dev);
 
 	return ret;
 }
@@ -514,12 +509,8 @@ static int ad5064_remove(struct device *dev)
 
 	iio_device_unregister(indio_dev);
 
-	if (!st->use_internal_vref) {
+	if (!st->use_internal_vref)
 		regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
-		regulator_bulk_free(ad5064_num_vref(st), st->vref_reg);
-	}
-
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2013-08-20 13:47 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 03/14] iio: dac: ad5380: " Sachin Kamat
2013-08-19 19:23   ` 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

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).