diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-19 07:38:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-19 15:26:25 -0400 |
commit | cd5e5785417591deba06b5fe3e78137137d2a9d3 (patch) | |
tree | 00e3c1fa31a49d2c5dd882950b101c15149f4c47 /drivers/iio | |
parent | ba7272954ec933eca3e459ac45003c0073a86993 (diff) |
iio: dac: ad5449: Use devm_* APIs
devm_* APIs are device managed and make code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/dac/ad5449.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c index ba1c914b0399..fff7d0762c0c 100644 --- a/drivers/iio/dac/ad5449.c +++ b/drivers/iio/dac/ad5449.c | |||
@@ -275,7 +275,7 @@ static int ad5449_spi_probe(struct spi_device *spi) | |||
275 | unsigned int i; | 275 | unsigned int i; |
276 | int ret; | 276 | int ret; |
277 | 277 | ||
278 | indio_dev = iio_device_alloc(sizeof(*st)); | 278 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
279 | if (indio_dev == NULL) | 279 | if (indio_dev == NULL) |
280 | return -ENOMEM; | 280 | return -ENOMEM; |
281 | 281 | ||
@@ -288,14 +288,14 @@ static int ad5449_spi_probe(struct spi_device *spi) | |||
288 | for (i = 0; i < st->chip_info->num_channels; ++i) | 288 | for (i = 0; i < st->chip_info->num_channels; ++i) |
289 | st->vref_reg[i].supply = ad5449_vref_name(st, i); | 289 | st->vref_reg[i].supply = ad5449_vref_name(st, i); |
290 | 290 | ||
291 | ret = regulator_bulk_get(&spi->dev, st->chip_info->num_channels, | 291 | ret = devm_regulator_bulk_get(&spi->dev, st->chip_info->num_channels, |
292 | st->vref_reg); | 292 | st->vref_reg); |
293 | if (ret) | 293 | if (ret) |
294 | goto error_free; | 294 | return ret; |
295 | 295 | ||
296 | ret = regulator_bulk_enable(st->chip_info->num_channels, st->vref_reg); | 296 | ret = regulator_bulk_enable(st->chip_info->num_channels, st->vref_reg); |
297 | if (ret) | 297 | if (ret) |
298 | goto error_free_reg; | 298 | return ret; |
299 | 299 | ||
300 | indio_dev->dev.parent = &spi->dev; | 300 | indio_dev->dev.parent = &spi->dev; |
301 | indio_dev->name = id->name; | 301 | indio_dev->name = id->name; |
@@ -325,10 +325,6 @@ static int ad5449_spi_probe(struct spi_device *spi) | |||
325 | 325 | ||
326 | error_disable_reg: | 326 | error_disable_reg: |
327 | regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); | 327 | regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); |
328 | error_free_reg: | ||
329 | regulator_bulk_free(st->chip_info->num_channels, st->vref_reg); | ||
330 | error_free: | ||
331 | iio_device_free(indio_dev); | ||
332 | 328 | ||
333 | return ret; | 329 | return ret; |
334 | } | 330 | } |
@@ -341,9 +337,6 @@ static int ad5449_spi_remove(struct spi_device *spi) | |||
341 | iio_device_unregister(indio_dev); | 337 | iio_device_unregister(indio_dev); |
342 | 338 | ||
343 | regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); | 339 | regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); |
344 | regulator_bulk_free(st->chip_info->num_channels, st->vref_reg); | ||
345 | |||
346 | iio_device_free(indio_dev); | ||
347 | 340 | ||
348 | return 0; | 341 | return 0; |
349 | } | 342 | } |