summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJinjie Ruan <ruanjinjie@huawei.com>2023-08-26 14:27:32 +0800
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2023-09-11 20:12:40 +0100
commitb564b99de79cdc87008dab3b19ae67a011f3f2fa (patch)
tree36e235d626aab8ed413dbbca20663f05e881a363 /drivers
parent3878ae2a1a7636be7009e20b48d4fc00adab8cf4 (diff)
downloadlinux-stable-b564b99de79cdc87008dab3b19ae67a011f3f2fa.tar.gz
linux-stable-b564b99de79cdc87008dab3b19ae67a011f3f2fa.tar.bz2
linux-stable-b564b99de79cdc87008dab3b19ae67a011f3f2fa.zip
iio: adc: spear_adc: Use dev_err_probe()
Use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230826062733.3714169-3-ruanjinjie@huawei.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/adc/spear_adc.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
index d24adacfdf53..71362c2ddf89 100644
--- a/drivers/iio/adc/spear_adc.c
+++ b/drivers/iio/adc/spear_adc.c
@@ -274,10 +274,9 @@ static int spear_adc_probe(struct platform_device *pdev)
int irq;
indio_dev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state));
- if (!indio_dev) {
- dev_err(dev, "failed allocating iio device\n");
- return -ENOMEM;
- }
+ if (!indio_dev)
+ return dev_err_probe(dev, -ENOMEM,
+ "failed allocating iio device\n");
st = iio_priv(indio_dev);
@@ -298,10 +297,9 @@ static int spear_adc_probe(struct platform_device *pdev)
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
st->clk = devm_clk_get_enabled(dev, NULL);
- if (IS_ERR(st->clk)) {
- dev_err(dev, "failed enabling clock\n");
- return PTR_ERR(st->clk);
- }
+ if (IS_ERR(st->clk))
+ return dev_err_probe(dev, PTR_ERR(st->clk),
+ "failed enabling clock\n");
irq = platform_get_irq(pdev, 0);
if (irq < 0)
@@ -309,16 +307,13 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME,
st);
- if (ret < 0) {
- dev_err(dev, "failed requesting interrupt\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "failed requesting interrupt\n");
if (of_property_read_u32(np, "sampling-frequency",
- &st->sampling_freq)) {
- dev_err(dev, "sampling-frequency missing in DT\n");
- return -EINVAL;
- }
+ &st->sampling_freq))
+ return dev_err_probe(dev, -EINVAL,
+ "sampling-frequency missing in DT\n");
/*
* Optional avg_samples defaults to 0, resulting in single data