summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2022-10-16 18:09:48 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2022-11-23 19:44:04 +0000
commitc247e0d8c0d50793f459d2a7997d2f8f2105c973 (patch)
tree06aa9fb14f754f07f0cb7e642d8191e4ba7d3d3f
parentdc0ba516d103532b7f289b20119374fe3797f81b (diff)
downloadlinux-c247e0d8c0d50793f459d2a7997d2f8f2105c973.tar.bz2
iio: adc: cc10001: Use devm_clk_get_enabled() to avoid boilerplate.
As this driver just enables clock in probe() and disables in remove() we can use this new function to replace boilerplate and simplify error paths. 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-4-jic23@kernel.org
-rw-r--r--drivers/iio/adc/cc10001_adc.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 4f42ceb40ded..1a3a5e0a52f7 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -352,23 +352,16 @@ static int cc10001_adc_probe(struct platform_device *pdev)
if (IS_ERR(adc_dev->reg_base))
return PTR_ERR(adc_dev->reg_base);
- adc_dev->adc_clk = devm_clk_get(dev, "adc");
+ adc_dev->adc_clk = devm_clk_get_enabled(dev, "adc");
if (IS_ERR(adc_dev->adc_clk)) {
- dev_err(dev, "failed to get the clock\n");
+ dev_err(dev, "failed to get/enable the clock\n");
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");
- return ret;
- }
-
adc_clk_rate = clk_get_rate(adc_dev->adc_clk);
if (!adc_clk_rate) {
- ret = -EINVAL;
dev_err(dev, "null clock rate!\n");
- goto err_disable_clk;
+ return -EINVAL;
}
adc_dev->eoc_delay_ns = NSEC_PER_SEC / adc_clk_rate;
@@ -385,14 +378,14 @@ static int cc10001_adc_probe(struct platform_device *pdev)
/* Setup the ADC channels available on the device */
ret = cc10001_adc_channel_init(indio_dev, channel_map);
if (ret < 0)
- goto err_disable_clk;
+ return ret;
mutex_init(&adc_dev->lock);
ret = iio_triggered_buffer_setup(indio_dev, NULL,
&cc10001_adc_trigger_h, NULL);
if (ret < 0)
- goto err_disable_clk;
+ return ret;
ret = iio_device_register(indio_dev);
if (ret < 0)
@@ -404,8 +397,6 @@ static int cc10001_adc_probe(struct platform_device *pdev)
err_cleanup_buffer:
iio_triggered_buffer_cleanup(indio_dev);
-err_disable_clk:
- clk_disable_unprepare(adc_dev->adc_clk);
return ret;
}
@@ -417,7 +408,6 @@ static int cc10001_adc_remove(struct platform_device *pdev)
cc10001_adc_power_down(adc_dev);
iio_device_unregister(indio_dev);
iio_triggered_buffer_cleanup(indio_dev);
- clk_disable_unprepare(adc_dev->adc_clk);
return 0;
}