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:20:28 -0400 |
commit | c367982ad9b927ec1b1fd66a462b72950fe5370b (patch) | |
tree | 7eff313a8f5c883875b2f20b6565c42cbfaf6acb /drivers/iio | |
parent | fa659a40b80b06140390c364362d7ca942e2b2f6 (diff) |
iio: dac: ad5064: 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/ad5064.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index aa26d50ab638..a3a52be4852c 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c | |||
@@ -442,7 +442,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, | |||
442 | unsigned int i; | 442 | unsigned int i; |
443 | int ret; | 443 | int ret; |
444 | 444 | ||
445 | indio_dev = iio_device_alloc(sizeof(*st)); | 445 | indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); |
446 | if (indio_dev == NULL) | 446 | if (indio_dev == NULL) |
447 | return -ENOMEM; | 447 | return -ENOMEM; |
448 | 448 | ||
@@ -456,23 +456,23 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, | |||
456 | for (i = 0; i < ad5064_num_vref(st); ++i) | 456 | for (i = 0; i < ad5064_num_vref(st); ++i) |
457 | st->vref_reg[i].supply = ad5064_vref_name(st, i); | 457 | st->vref_reg[i].supply = ad5064_vref_name(st, i); |
458 | 458 | ||
459 | ret = regulator_bulk_get(dev, ad5064_num_vref(st), | 459 | ret = devm_regulator_bulk_get(dev, ad5064_num_vref(st), |
460 | st->vref_reg); | 460 | st->vref_reg); |
461 | if (ret) { | 461 | if (ret) { |
462 | if (!st->chip_info->internal_vref) | 462 | if (!st->chip_info->internal_vref) |
463 | goto error_free; | 463 | return ret; |
464 | st->use_internal_vref = true; | 464 | st->use_internal_vref = true; |
465 | ret = ad5064_write(st, AD5064_CMD_CONFIG, 0, | 465 | ret = ad5064_write(st, AD5064_CMD_CONFIG, 0, |
466 | AD5064_CONFIG_INT_VREF_ENABLE, 0); | 466 | AD5064_CONFIG_INT_VREF_ENABLE, 0); |
467 | if (ret) { | 467 | if (ret) { |
468 | dev_err(dev, "Failed to enable internal vref: %d\n", | 468 | dev_err(dev, "Failed to enable internal vref: %d\n", |
469 | ret); | 469 | ret); |
470 | goto error_free; | 470 | return ret; |
471 | } | 471 | } |
472 | } else { | 472 | } else { |
473 | ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); | 473 | ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); |
474 | if (ret) | 474 | if (ret) |
475 | goto error_free_reg; | 475 | return ret; |
476 | } | 476 | } |
477 | 477 | ||
478 | indio_dev->dev.parent = dev; | 478 | indio_dev->dev.parent = dev; |
@@ -498,11 +498,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, | |||
498 | error_disable_reg: | 498 | error_disable_reg: |
499 | if (!st->use_internal_vref) | 499 | if (!st->use_internal_vref) |
500 | regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); | 500 | regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); |
501 | error_free_reg: | ||
502 | if (!st->use_internal_vref) | ||
503 | regulator_bulk_free(ad5064_num_vref(st), st->vref_reg); | ||
504 | error_free: | ||
505 | iio_device_free(indio_dev); | ||
506 | 501 | ||
507 | return ret; | 502 | return ret; |
508 | } | 503 | } |
@@ -514,12 +509,8 @@ static int ad5064_remove(struct device *dev) | |||
514 | 509 | ||
515 | iio_device_unregister(indio_dev); | 510 | iio_device_unregister(indio_dev); |
516 | 511 | ||
517 | if (!st->use_internal_vref) { | 512 | if (!st->use_internal_vref) |
518 | regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); | 513 | regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); |
519 | regulator_bulk_free(ad5064_num_vref(st), st->vref_reg); | ||
520 | } | ||
521 | |||
522 | iio_device_free(indio_dev); | ||
523 | 514 | ||
524 | return 0; | 515 | return 0; |
525 | } | 516 | } |