diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-07-23 07:50:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-03 18:40:38 +0100 |
commit | ded4fef934768adee9d31f15831513d7d76c360b (patch) | |
tree | b9e59ada799b3c8d8ccc397d0a01cc1be8bb9c46 /drivers/iio/adc/ad7266.c | |
parent | 03eff7b60dc3e5d2539a5f9685a9fb9a530e01e8 (diff) |
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.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index c2744a75c3b..371731df163 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; } |