summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoniu Miclaus <antoniu.miclaus@analog.com>2026-03-13 13:57:43 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2026-03-21 21:12:24 +0000
commit9582a65eda4f566df9dc329e70f8be48260a9c9d (patch)
treed6feac8c2ce524773b09cc4ad561b1ee781e3e15
parent7428168fe1615423685fa61e4d38bd2e20f14ebd (diff)
iio: frequency: ad9523: add dev variable
Introduce a local struct device variable in ad9523_probe() to simplify subsequent conversions and improve code readability. Split pdata declaration and assignment since the result is validated immediately after. No functional change. 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>
-rw-r--r--drivers/iio/frequency/ad9523.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index ad32eb66edca..f4e80ea0c6d2 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -948,17 +948,19 @@ static int ad9523_setup(struct iio_dev *indio_dev)
static int ad9523_probe(struct spi_device *spi)
{
- struct ad9523_platform_data *pdata = dev_get_platdata(&spi->dev);
+ struct device *dev = &spi->dev;
+ struct ad9523_platform_data *pdata;
struct iio_dev *indio_dev;
struct ad9523_state *st;
int ret;
+ pdata = dev_get_platdata(dev);
if (!pdata) {
dev_err(&spi->dev, "no platform data?\n");
return -EINVAL;
}
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -966,16 +968,16 @@ static int ad9523_probe(struct spi_device *spi)
mutex_init(&st->lock);
- ret = devm_regulator_get_enable(&spi->dev, "vcc");
+ ret = devm_regulator_get_enable(dev, "vcc");
if (ret)
return ret;
- st->pwrdown_gpio = devm_gpiod_get_optional(&spi->dev, "powerdown",
+ st->pwrdown_gpio = devm_gpiod_get_optional(dev, "powerdown",
GPIOD_OUT_HIGH);
if (IS_ERR(st->pwrdown_gpio))
return PTR_ERR(st->pwrdown_gpio);
- st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
+ st->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(st->reset_gpio))
return PTR_ERR(st->reset_gpio);
@@ -985,7 +987,7 @@ static int ad9523_probe(struct spi_device *spi)
gpiod_direction_output(st->reset_gpio, 1);
}
- st->sync_gpio = devm_gpiod_get_optional(&spi->dev, "sync",
+ st->sync_gpio = devm_gpiod_get_optional(dev, "sync",
GPIOD_OUT_HIGH);
if (IS_ERR(st->sync_gpio))
return PTR_ERR(st->sync_gpio);
@@ -1005,7 +1007,7 @@ static int ad9523_probe(struct spi_device *spi)
if (ret < 0)
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 ad9523_id[] = {