summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ad7266.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-23 08:50:00 +0200
committerJonathan Cameron <jic23@kernel.org>2013-08-03 19:40:38 +0200
commitded4fef934768adee9d31f15831513d7d76c360b (patch)
treeb9e59ada799b3c8d8ccc397d0a01cc1be8bb9c46 /drivers/iio/adc/ad7266.c
parentiio: add APDS9300 ambilent light sensor driver (diff)
downloadlinux-ded4fef934768adee9d31f15831513d7d76c360b.tar.xz
linux-ded4fef934768adee9d31f15831513d7d76c360b.zip
iio: adc: ad7266: Use devm_* APIs
devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc/ad7266.c')
-rw-r--r--drivers/iio/adc/ad7266.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index c2744a75c3b0..371731df1634 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;
}