iio: adc: spear_adc: Use dev_err_probe()
authorJinjie Ruan <ruanjinjie@huawei.com>
Sat, 26 Aug 2023 06:27:32 +0000 (14:27 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 11 Sep 2023 19:12:40 +0000 (20:12 +0100)
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>
drivers/iio/adc/spear_adc.c

index d24adacfdf539cc253382b58d14697e3b26393b8..71362c2ddf897dac57a943b05eaba53138f86180 100644 (file)
@@ -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