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:23:53 -0400 |
commit | c815ad372be668bd6f173439be1f67e0d7dc4e5b (patch) | |
tree | f234cdda7d17730aea6d4b475ac1cacb29276c37 | |
parent | 400d36e68de56135223ace631f4bb067d9ccb44d (diff) |
iio: dac: ad5380: 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>
-rw-r--r-- | drivers/iio/dac/ad5380.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index bf2db02215c2..1c44ae3920e2 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c | |||
@@ -369,11 +369,10 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, | |||
369 | unsigned int ctrl = 0; | 369 | unsigned int ctrl = 0; |
370 | int ret; | 370 | int ret; |
371 | 371 | ||
372 | indio_dev = iio_device_alloc(sizeof(*st)); | 372 | indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); |
373 | if (indio_dev == NULL) { | 373 | if (indio_dev == NULL) { |
374 | dev_err(dev, "Failed to allocate iio device\n"); | 374 | dev_err(dev, "Failed to allocate iio device\n"); |
375 | ret = -ENOMEM; | 375 | return -ENOMEM; |
376 | goto error_out; | ||
377 | } | 376 | } |
378 | 377 | ||
379 | st = iio_priv(indio_dev); | 378 | st = iio_priv(indio_dev); |
@@ -391,13 +390,13 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, | |||
391 | ret = ad5380_alloc_channels(indio_dev); | 390 | ret = ad5380_alloc_channels(indio_dev); |
392 | if (ret) { | 391 | if (ret) { |
393 | dev_err(dev, "Failed to allocate channel spec: %d\n", ret); | 392 | dev_err(dev, "Failed to allocate channel spec: %d\n", ret); |
394 | goto error_free; | 393 | return ret; |
395 | } | 394 | } |
396 | 395 | ||
397 | if (st->chip_info->int_vref == 2500000) | 396 | if (st->chip_info->int_vref == 2500000) |
398 | ctrl |= AD5380_CTRL_INT_VREF_2V5; | 397 | ctrl |= AD5380_CTRL_INT_VREF_2V5; |
399 | 398 | ||
400 | st->vref_reg = regulator_get(dev, "vref"); | 399 | st->vref_reg = devm_regulator_get(dev, "vref"); |
401 | if (!IS_ERR(st->vref_reg)) { | 400 | if (!IS_ERR(st->vref_reg)) { |
402 | ret = regulator_enable(st->vref_reg); | 401 | ret = regulator_enable(st->vref_reg); |
403 | if (ret) { | 402 | if (ret) { |
@@ -434,13 +433,7 @@ error_disable_reg: | |||
434 | if (!IS_ERR(st->vref_reg)) | 433 | if (!IS_ERR(st->vref_reg)) |
435 | regulator_disable(st->vref_reg); | 434 | regulator_disable(st->vref_reg); |
436 | error_free_reg: | 435 | error_free_reg: |
437 | if (!IS_ERR(st->vref_reg)) | ||
438 | regulator_put(st->vref_reg); | ||
439 | |||
440 | kfree(indio_dev->channels); | 436 | kfree(indio_dev->channels); |
441 | error_free: | ||
442 | iio_device_free(indio_dev); | ||
443 | error_out: | ||
444 | 437 | ||
445 | return ret; | 438 | return ret; |
446 | } | 439 | } |
@@ -456,11 +449,8 @@ static int ad5380_remove(struct device *dev) | |||
456 | 449 | ||
457 | if (!IS_ERR(st->vref_reg)) { | 450 | if (!IS_ERR(st->vref_reg)) { |
458 | regulator_disable(st->vref_reg); | 451 | regulator_disable(st->vref_reg); |
459 | regulator_put(st->vref_reg); | ||
460 | } | 452 | } |
461 | 453 | ||
462 | iio_device_free(indio_dev); | ||
463 | |||
464 | return 0; | 454 | return 0; |
465 | } | 455 | } |
466 | 456 | ||