iio: adc: cc10001: Add local struct device *dev variable to avoid repitition
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 16 Oct 2022 17:09:46 +0000 (18:09 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 23 Nov 2022 19:44:04 +0000 (19:44 +0000)
There are lots of uses of this in probe() and we are about to introduce
some more, so add a local variable to simplify this.

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-2-jic23@kernel.org
drivers/iio/adc/cc10001_adc.c

index e16ac93..eeaea13 100644 (file)
@@ -307,14 +307,15 @@ static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
 
 static int cc10001_adc_probe(struct platform_device *pdev)
 {
-       struct device_node *node = pdev->dev.of_node;
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->of_node;
        struct cc10001_adc_device *adc_dev;
        unsigned long adc_clk_rate;
        struct iio_dev *indio_dev;
        unsigned long channel_map;
        int ret;
 
-       indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
+       indio_dev = devm_iio_device_alloc(dev, sizeof(*adc_dev));
        if (indio_dev == NULL)
                return -ENOMEM;
 
@@ -326,7 +327,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
                channel_map &= ~ret;
        }
 
-       adc_dev->reg = devm_regulator_get(&pdev->dev, "vref");
+       adc_dev->reg = devm_regulator_get(dev, "vref");
        if (IS_ERR(adc_dev->reg))
                return PTR_ERR(adc_dev->reg);
 
@@ -334,7 +335,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       indio_dev->name = dev_name(&pdev->dev);
+       indio_dev->name = dev_name(dev);
        indio_dev->info = &cc10001_adc_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
 
@@ -344,23 +345,23 @@ static int cc10001_adc_probe(struct platform_device *pdev)
                goto err_disable_reg;
        }
 
-       adc_dev->adc_clk = devm_clk_get(&pdev->dev, "adc");
+       adc_dev->adc_clk = devm_clk_get(dev, "adc");
        if (IS_ERR(adc_dev->adc_clk)) {
-               dev_err(&pdev->dev, "failed to get the clock\n");
+               dev_err(dev, "failed to get the clock\n");
                ret = PTR_ERR(adc_dev->adc_clk);
                goto err_disable_reg;
        }
 
        ret = clk_prepare_enable(adc_dev->adc_clk);
        if (ret) {
-               dev_err(&pdev->dev, "failed to enable the clock\n");
+               dev_err(dev, "failed to enable the clock\n");
                goto err_disable_reg;
        }
 
        adc_clk_rate = clk_get_rate(adc_dev->adc_clk);
        if (!adc_clk_rate) {
                ret = -EINVAL;
-               dev_err(&pdev->dev, "null clock rate!\n");
+               dev_err(dev, "null clock rate!\n");
                goto err_disable_clk;
        }