]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: frequency: adf4377: add dev variable
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Fri, 27 Feb 2026 14:01:36 +0000 (16:01 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 28 Feb 2026 11:35:17 +0000 (11:35 +0000)
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/frequency/adf4377.c

index fa686f785fa43f2ae1101578d139539c9b6e6874..c2ae6f2012ce19e64e02ae1bd0104d330a683bc8 100644 (file)
@@ -882,35 +882,35 @@ static const struct iio_chan_spec adf4377_channels[] = {
 
 static int adf4377_properties_parse(struct adf4377_state *st)
 {
-       struct spi_device *spi = st->spi;
+       struct device *dev = &st->spi->dev;
        int ret;
 
-       st->clkin = devm_clk_get_enabled(&spi->dev, "ref_in");
+       st->clkin = devm_clk_get_enabled(dev, "ref_in");
        if (IS_ERR(st->clkin))
-               return dev_err_probe(&spi->dev, PTR_ERR(st->clkin),
+               return dev_err_probe(dev, PTR_ERR(st->clkin),
                                     "failed to get the reference input clock\n");
 
-       st->gpio_ce = devm_gpiod_get_optional(&st->spi->dev, "chip-enable",
+       st->gpio_ce = devm_gpiod_get_optional(dev, "chip-enable",
                                              GPIOD_OUT_LOW);
        if (IS_ERR(st->gpio_ce))
-               return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_ce),
+               return dev_err_probe(dev, PTR_ERR(st->gpio_ce),
                                     "failed to get the CE GPIO\n");
 
-       st->gpio_enclk1 = devm_gpiod_get_optional(&st->spi->dev, "clk1-enable",
+       st->gpio_enclk1 = devm_gpiod_get_optional(dev, "clk1-enable",
                                                  GPIOD_OUT_LOW);
        if (IS_ERR(st->gpio_enclk1))
-               return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1),
+               return dev_err_probe(dev, PTR_ERR(st->gpio_enclk1),
                                     "failed to get the CE GPIO\n");
 
        if (st->chip_info->has_gpio_enclk2) {
-               st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
+               st->gpio_enclk2 = devm_gpiod_get_optional(dev, "clk2-enable",
                                                          GPIOD_OUT_LOW);
                if (IS_ERR(st->gpio_enclk2))
-                       return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
+                       return dev_err_probe(dev, PTR_ERR(st->gpio_enclk2),
                                        "failed to get the CE GPIO\n");
        }
 
-       ret = device_property_match_property_string(&spi->dev, "adi,muxout-select",
+       ret = device_property_match_property_string(dev, "adi,muxout-select",
                                                    adf4377_muxout_modes,
                                                    ARRAY_SIZE(adf4377_muxout_modes));
        if (ret >= 0)
@@ -1055,9 +1055,10 @@ static int adf4377_probe(struct spi_device *spi)
        struct iio_dev *indio_dev;
        struct regmap *regmap;
        struct adf4377_state *st;
+       struct device *dev = &spi->dev;
        int ret;
 
-       indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+       indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
        if (!indio_dev)
                return -ENOMEM;
 
@@ -1080,7 +1081,7 @@ static int adf4377_probe(struct spi_device *spi)
                return ret;
 
        st->nb.notifier_call = adf4377_freq_change;
-       ret = devm_clk_notifier_register(&spi->dev, st->clkin, &st->nb);
+       ret = devm_clk_notifier_register(dev, st->clkin, &st->nb);
        if (ret)
                return ret;
 
@@ -1097,7 +1098,7 @@ static int adf4377_probe(struct spi_device *spi)
                indio_dev->num_channels = ARRAY_SIZE(adf4377_channels);
        }
 
-       return devm_iio_device_register(&spi->dev, indio_dev);
+       return devm_iio_device_register(dev, indio_dev);
 }
 
 static const struct spi_device_id adf4377_id[] = {