Commit ded4fef934768adee9d31f15831513d7d76c360b
Committed by
Jonathan Cameron
1 parent
03eff7b60d
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
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>
Showing 1 changed file with 4 additions and 12 deletions Side-by-side Diff
drivers/iio/adc/ad7266.c
... | ... | @@ -399,17 +399,17 @@ |
399 | 399 | unsigned int i; |
400 | 400 | int ret; |
401 | 401 | |
402 | - indio_dev = iio_device_alloc(sizeof(*st)); | |
402 | + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); | |
403 | 403 | if (indio_dev == NULL) |
404 | 404 | return -ENOMEM; |
405 | 405 | |
406 | 406 | st = iio_priv(indio_dev); |
407 | 407 | |
408 | - st->reg = regulator_get(&spi->dev, "vref"); | |
408 | + st->reg = devm_regulator_get(&spi->dev, "vref"); | |
409 | 409 | if (!IS_ERR_OR_NULL(st->reg)) { |
410 | 410 | ret = regulator_enable(st->reg); |
411 | 411 | if (ret) |
412 | - goto error_put_reg; | |
412 | + return ret; | |
413 | 413 | |
414 | 414 | ret = regulator_get_voltage(st->reg); |
415 | 415 | if (ret < 0) |
416 | 416 | |
... | ... | @@ -489,12 +489,7 @@ |
489 | 489 | error_disable_reg: |
490 | 490 | if (!IS_ERR_OR_NULL(st->reg)) |
491 | 491 | regulator_disable(st->reg); |
492 | -error_put_reg: | |
493 | - if (!IS_ERR_OR_NULL(st->reg)) | |
494 | - regulator_put(st->reg); | |
495 | 492 | |
496 | - iio_device_free(indio_dev); | |
497 | - | |
498 | 493 | return ret; |
499 | 494 | } |
500 | 495 | |
501 | 496 | |
... | ... | @@ -507,11 +502,8 @@ |
507 | 502 | iio_triggered_buffer_cleanup(indio_dev); |
508 | 503 | if (!st->fixed_addr) |
509 | 504 | gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios)); |
510 | - if (!IS_ERR_OR_NULL(st->reg)) { | |
505 | + if (!IS_ERR_OR_NULL(st->reg)) | |
511 | 506 | regulator_disable(st->reg); |
512 | - regulator_put(st->reg); | |
513 | - } | |
514 | - iio_device_free(indio_dev); | |
515 | 507 | |
516 | 508 | return 0; |
517 | 509 | } |