summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/cc10001_adc.c
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2022-10-16 18:09:49 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2022-11-23 19:44:04 +0000
commita43d5155b9455d38c4b3e4656131d79af61a2978 (patch)
tree22895e9366a771b611fe019fb2a05c88f74a8449 /drivers/iio/adc/cc10001_adc.c
parentc247e0d8c0d50793f459d2a7997d2f8f2105c973 (diff)
downloadlinux-a43d5155b9455d38c4b3e4656131d79af61a2978.tar.bz2
iio: adc: cc10001: Use devm_ to call device power down.
It is presumably safe to call the powerdown whether or not we are in the commented shared state (the driver always did this). The power down was previously out of order wrt to the probe() function so move using devm_ will ensure it occurs after the userspace interfaces are removed. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20221016170950.387751-5-jic23@kernel.org
Diffstat (limited to 'drivers/iio/adc/cc10001_adc.c')
-rw-r--r--drivers/iio/adc/cc10001_adc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 1a3a5e0a52f7..aecad89c00ff 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -310,6 +310,11 @@ static void cc10001_reg_disable(void *priv)
regulator_disable(priv);
}
+static void cc10001_pd_cb(void *priv)
+{
+ cc10001_adc_power_down(priv);
+}
+
static int cc10001_adc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -375,6 +380,9 @@ static int cc10001_adc_probe(struct platform_device *pdev)
if (adc_dev->shared)
cc10001_adc_power_up(adc_dev);
+ ret = devm_add_action_or_reset(dev, cc10001_pd_cb, adc_dev);
+ if (ret)
+ return ret;
/* Setup the ADC channels available on the device */
ret = cc10001_adc_channel_init(indio_dev, channel_map);
if (ret < 0)
@@ -405,7 +413,6 @@ static int cc10001_adc_remove(struct platform_device *pdev)
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct cc10001_adc_device *adc_dev = iio_priv(indio_dev);
- cc10001_adc_power_down(adc_dev);
iio_device_unregister(indio_dev);
iio_triggered_buffer_cleanup(indio_dev);