aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/frequency
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-30 02:24:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 16:01:27 -0400
commitb46400c639de7b0b3abce226b7ba0cbb253a4806 (patch)
tree9cd271c0651ea81988f8cada7e94d4641e800c65 /drivers/iio/frequency
parent36db8c72169489eedca06fe308b1643256d8c4fe (diff)
iio: frequency: ad9523: Use devm_* APIs
devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Michael Hennerich <hennerich@blackfin.uclinux.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/frequency')
-rw-r--r--drivers/iio/frequency/ad9523.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 92276deeb026..7c5245d9f99c 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -961,17 +961,17 @@ static int ad9523_probe(struct spi_device *spi)
961 return -EINVAL; 961 return -EINVAL;
962 } 962 }
963 963
964 indio_dev = iio_device_alloc(sizeof(*st)); 964 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
965 if (indio_dev == NULL) 965 if (indio_dev == NULL)
966 return -ENOMEM; 966 return -ENOMEM;
967 967
968 st = iio_priv(indio_dev); 968 st = iio_priv(indio_dev);
969 969
970 st->reg = regulator_get(&spi->dev, "vcc"); 970 st->reg = devm_regulator_get(&spi->dev, "vcc");
971 if (!IS_ERR(st->reg)) { 971 if (!IS_ERR(st->reg)) {
972 ret = regulator_enable(st->reg); 972 ret = regulator_enable(st->reg);
973 if (ret) 973 if (ret)
974 goto error_put_reg; 974 return ret;
975 } 975 }
976 976
977 spi_set_drvdata(spi, indio_dev); 977 spi_set_drvdata(spi, indio_dev);
@@ -1001,11 +1001,6 @@ static int ad9523_probe(struct spi_device *spi)
1001error_disable_reg: 1001error_disable_reg:
1002 if (!IS_ERR(st->reg)) 1002 if (!IS_ERR(st->reg))
1003 regulator_disable(st->reg); 1003 regulator_disable(st->reg);
1004error_put_reg:
1005 if (!IS_ERR(st->reg))
1006 regulator_put(st->reg);
1007
1008 iio_device_free(indio_dev);
1009 1004
1010 return ret; 1005 return ret;
1011} 1006}
@@ -1017,12 +1012,8 @@ static int ad9523_remove(struct spi_device *spi)
1017 1012
1018 iio_device_unregister(indio_dev); 1013 iio_device_unregister(indio_dev);
1019 1014
1020 if (!IS_ERR(st->reg)) { 1015 if (!IS_ERR(st->reg))
1021 regulator_disable(st->reg); 1016 regulator_disable(st->reg);
1022 regulator_put(st->reg);
1023 }
1024
1025 iio_device_free(indio_dev);
1026 1017
1027 return 0; 1018 return 0;
1028} 1019}