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:35:32 -0400 |
commit | 7ff0de3faaeb0db80c2c9f03c119167e89594879 (patch) | |
tree | afc770e3e9a28c8cfb869dd5a6ea6b9e926efaff /drivers/iio | |
parent | fd047294e279779c36cbca589d9fef06e881e67a (diff) |
iio: dac: ad5764: 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/ad5764.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index 7a53f7d70dac..df7e028d9db5 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c | |||
@@ -275,7 +275,7 @@ static int ad5764_probe(struct spi_device *spi) | |||
275 | struct ad5764_state *st; | 275 | struct ad5764_state *st; |
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 | dev_err(&spi->dev, "Failed to allocate iio device\n"); | 280 | dev_err(&spi->dev, "Failed to allocate iio device\n"); |
281 | return -ENOMEM; | 281 | return -ENOMEM; |
@@ -298,12 +298,12 @@ static int ad5764_probe(struct spi_device *spi) | |||
298 | st->vref_reg[0].supply = "vrefAB"; | 298 | st->vref_reg[0].supply = "vrefAB"; |
299 | st->vref_reg[1].supply = "vrefCD"; | 299 | st->vref_reg[1].supply = "vrefCD"; |
300 | 300 | ||
301 | ret = regulator_bulk_get(&st->spi->dev, | 301 | ret = devm_regulator_bulk_get(&st->spi->dev, |
302 | ARRAY_SIZE(st->vref_reg), st->vref_reg); | 302 | ARRAY_SIZE(st->vref_reg), st->vref_reg); |
303 | if (ret) { | 303 | if (ret) { |
304 | dev_err(&spi->dev, "Failed to request vref regulators: %d\n", | 304 | dev_err(&spi->dev, "Failed to request vref regulators: %d\n", |
305 | ret); | 305 | ret); |
306 | goto error_free; | 306 | return ret; |
307 | } | 307 | } |
308 | 308 | ||
309 | ret = regulator_bulk_enable(ARRAY_SIZE(st->vref_reg), | 309 | ret = regulator_bulk_enable(ARRAY_SIZE(st->vref_reg), |
@@ -311,7 +311,7 @@ static int ad5764_probe(struct spi_device *spi) | |||
311 | if (ret) { | 311 | if (ret) { |
312 | dev_err(&spi->dev, "Failed to enable vref regulators: %d\n", | 312 | dev_err(&spi->dev, "Failed to enable vref regulators: %d\n", |
313 | ret); | 313 | ret); |
314 | goto error_free_reg; | 314 | return ret; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
@@ -326,12 +326,6 @@ static int ad5764_probe(struct spi_device *spi) | |||
326 | error_disable_reg: | 326 | error_disable_reg: |
327 | if (st->chip_info->int_vref == 0) | 327 | if (st->chip_info->int_vref == 0) |
328 | regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg); | 328 | regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg); |
329 | error_free_reg: | ||
330 | if (st->chip_info->int_vref == 0) | ||
331 | regulator_bulk_free(ARRAY_SIZE(st->vref_reg), st->vref_reg); | ||
332 | error_free: | ||
333 | iio_device_free(indio_dev); | ||
334 | |||
335 | return ret; | 329 | return ret; |
336 | } | 330 | } |
337 | 331 | ||
@@ -342,12 +336,8 @@ static int ad5764_remove(struct spi_device *spi) | |||
342 | 336 | ||
343 | iio_device_unregister(indio_dev); | 337 | iio_device_unregister(indio_dev); |
344 | 338 | ||
345 | if (st->chip_info->int_vref == 0) { | 339 | if (st->chip_info->int_vref == 0) |
346 | regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg); | 340 | regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg); |
347 | regulator_bulk_free(ARRAY_SIZE(st->vref_reg), st->vref_reg); | ||
348 | } | ||
349 | |||
350 | iio_device_free(indio_dev); | ||
351 | 341 | ||
352 | return 0; | 342 | return 0; |
353 | } | 343 | } |