]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: filter: admv8818: add dev variable
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Fri, 27 Feb 2026 14:01:40 +0000 (16:01 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 28 Feb 2026 11:35:30 +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/filter/admv8818.c

index e494fd33911bd21b37f4868592224904e822d6ae..c83e729534e7e3ed6fb99780a04f4dc933348bde 100644 (file)
@@ -701,12 +701,12 @@ static int admv8818_init(struct admv8818_state *st)
 
 static int admv8818_clk_setup(struct admv8818_state *st)
 {
-       struct spi_device *spi = st->spi;
+       struct device *dev = &st->spi->dev;
        int ret;
 
-       st->clkin = devm_clk_get_optional(&spi->dev, "rf_in");
+       st->clkin = devm_clk_get_optional(dev, "rf_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 input clock\n");
        else if (!st->clkin)
                return 0;
@@ -715,7 +715,7 @@ static int admv8818_clk_setup(struct admv8818_state *st)
        if (ret)
                return ret;
 
-       ret = devm_add_action_or_reset(&spi->dev, admv8818_clk_disable, st);
+       ret = devm_add_action_or_reset(dev, admv8818_clk_disable, st);
        if (ret)
                return ret;
 
@@ -724,16 +724,16 @@ static int admv8818_clk_setup(struct admv8818_state *st)
        if (ret < 0)
                return ret;
 
-       return devm_add_action_or_reset(&spi->dev, admv8818_clk_notifier_unreg, st);
+       return devm_add_action_or_reset(dev, admv8818_clk_notifier_unreg, st);
 }
 
 static int admv8818_read_properties(struct admv8818_state *st)
 {
-       struct spi_device *spi = st->spi;
+       struct device *dev = &st->spi->dev;
        u32 mhz;
        int ret;
 
-       ret = device_property_read_u32(&spi->dev, "adi,lpf-margin-mhz", &mhz);
+       ret = device_property_read_u32(dev, "adi,lpf-margin-mhz", &mhz);
        if (ret == 0)
                st->lpf_margin_hz = (u64)mhz * HZ_PER_MHZ;
        else if (ret == -EINVAL)
@@ -742,7 +742,7 @@ static int admv8818_read_properties(struct admv8818_state *st)
                return ret;
 
 
-       ret = device_property_read_u32(&spi->dev, "adi,hpf-margin-mhz", &mhz);
+       ret = device_property_read_u32(dev, "adi,hpf-margin-mhz", &mhz);
        if (ret == 0)
                st->hpf_margin_hz = (u64)mhz * HZ_PER_MHZ;
        else if (ret == -EINVAL)
@@ -758,9 +758,10 @@ static int admv8818_probe(struct spi_device *spi)
        struct iio_dev *indio_dev;
        struct regmap *regmap;
        struct admv8818_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;
 
@@ -792,7 +793,7 @@ static int admv8818_probe(struct spi_device *spi)
        if (ret)
                return ret;
 
-       return devm_iio_device_register(&spi->dev, indio_dev);
+       return devm_iio_device_register(dev, indio_dev);
 }
 
 static const struct spi_device_id admv8818_id[] = {