iio: frequency: adf4377: add dev variable

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>
This commit is contained in:
Antoniu Miclaus
2026-02-27 16:01:36 +02:00
committed by Jonathan Cameron
parent 9e9f38c44b
commit b2d2a6ea12

View 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[] = {