diff options
Diffstat (limited to 'drivers/iio/adc/ad7793.c')
-rw-r--r-- | drivers/iio/adc/ad7793.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c index 334e31ff7a4e..4dddeabdfbb0 100644 --- a/drivers/iio/adc/ad7793.c +++ b/drivers/iio/adc/ad7793.c | |||
@@ -757,7 +757,7 @@ static int ad7793_probe(struct spi_device *spi) | |||
757 | return -ENODEV; | 757 | return -ENODEV; |
758 | } | 758 | } |
759 | 759 | ||
760 | indio_dev = iio_device_alloc(sizeof(*st)); | 760 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
761 | if (indio_dev == NULL) | 761 | if (indio_dev == NULL) |
762 | return -ENOMEM; | 762 | return -ENOMEM; |
763 | 763 | ||
@@ -766,15 +766,13 @@ static int ad7793_probe(struct spi_device *spi) | |||
766 | ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info); | 766 | ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info); |
767 | 767 | ||
768 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) { | 768 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) { |
769 | st->reg = regulator_get(&spi->dev, "refin"); | 769 | st->reg = devm_regulator_get(&spi->dev, "refin"); |
770 | if (IS_ERR(st->reg)) { | 770 | if (IS_ERR(st->reg)) |
771 | ret = PTR_ERR(st->reg); | 771 | return PTR_ERR(st->reg); |
772 | goto error_device_free; | ||
773 | } | ||
774 | 772 | ||
775 | ret = regulator_enable(st->reg); | 773 | ret = regulator_enable(st->reg); |
776 | if (ret) | 774 | if (ret) |
777 | goto error_put_reg; | 775 | return ret; |
778 | 776 | ||
779 | vref_mv = regulator_get_voltage(st->reg); | 777 | vref_mv = regulator_get_voltage(st->reg); |
780 | if (vref_mv < 0) { | 778 | if (vref_mv < 0) { |
@@ -818,11 +816,6 @@ error_remove_trigger: | |||
818 | error_disable_reg: | 816 | error_disable_reg: |
819 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) | 817 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) |
820 | regulator_disable(st->reg); | 818 | regulator_disable(st->reg); |
821 | error_put_reg: | ||
822 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) | ||
823 | regulator_put(st->reg); | ||
824 | error_device_free: | ||
825 | iio_device_free(indio_dev); | ||
826 | 819 | ||
827 | return ret; | 820 | return ret; |
828 | } | 821 | } |
@@ -836,12 +829,8 @@ static int ad7793_remove(struct spi_device *spi) | |||
836 | iio_device_unregister(indio_dev); | 829 | iio_device_unregister(indio_dev); |
837 | ad_sd_cleanup_buffer_and_trigger(indio_dev); | 830 | ad_sd_cleanup_buffer_and_trigger(indio_dev); |
838 | 831 | ||
839 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) { | 832 | if (pdata->refsel != AD7793_REFSEL_INTERNAL) |
840 | regulator_disable(st->reg); | 833 | regulator_disable(st->reg); |
841 | regulator_put(st->reg); | ||
842 | } | ||
843 | |||
844 | iio_device_free(indio_dev); | ||
845 | 834 | ||
846 | return 0; | 835 | return 0; |
847 | } | 836 | } |