diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2022-10-16 18:09:47 +0100 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2022-11-23 19:44:04 +0000 |
commit | dc0ba516d103532b7f289b20119374fe3797f81b (patch) | |
tree | 17fa906912381bde8a1c1b565c7a73316b32f4a8 | |
parent | 26bfb581931a020eaf560612f01009b3e179db0a (diff) | |
download | linux-stable-dc0ba516d103532b7f289b20119374fe3797f81b.tar.gz linux-stable-dc0ba516d103532b7f289b20119374fe3797f81b.tar.bz2 linux-stable-dc0ba516d103532b7f289b20119374fe3797f81b.zip |
iio: adc: cc10001: Add devm_add_action_or_reset() to disable regulator.
As the voltage of this regulator is queried, we cannot use the
devm_regulator_get_enable() call and have to role our own disable.
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-3-jic23@kernel.org
-rw-r--r-- | drivers/iio/adc/cc10001_adc.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index eeaea1362ed1..4f42ceb40ded 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -305,6 +305,11 @@ static int cc10001_adc_channel_init(struct iio_dev *indio_dev, return 0; } +static void cc10001_reg_disable(void *priv) +{ + regulator_disable(priv); +} + static int cc10001_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -335,27 +340,28 @@ static int cc10001_adc_probe(struct platform_device *pdev) if (ret) return ret; + ret = devm_add_action_or_reset(dev, cc10001_reg_disable, adc_dev->reg); + if (ret) + return ret; + indio_dev->name = dev_name(dev); indio_dev->info = &cc10001_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; adc_dev->reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(adc_dev->reg_base)) { - ret = PTR_ERR(adc_dev->reg_base); - goto err_disable_reg; - } + if (IS_ERR(adc_dev->reg_base)) + return PTR_ERR(adc_dev->reg_base); adc_dev->adc_clk = devm_clk_get(dev, "adc"); if (IS_ERR(adc_dev->adc_clk)) { dev_err(dev, "failed to get the clock\n"); - ret = PTR_ERR(adc_dev->adc_clk); - goto err_disable_reg; + return PTR_ERR(adc_dev->adc_clk); } ret = clk_prepare_enable(adc_dev->adc_clk); if (ret) { dev_err(dev, "failed to enable the clock\n"); - goto err_disable_reg; + return ret; } adc_clk_rate = clk_get_rate(adc_dev->adc_clk); @@ -400,8 +406,6 @@ err_cleanup_buffer: iio_triggered_buffer_cleanup(indio_dev); err_disable_clk: clk_disable_unprepare(adc_dev->adc_clk); -err_disable_reg: - regulator_disable(adc_dev->reg); return ret; } @@ -414,7 +418,6 @@ static int cc10001_adc_remove(struct platform_device *pdev) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); clk_disable_unprepare(adc_dev->adc_clk); - regulator_disable(adc_dev->reg); return 0; } |