iio: frequency: use dev_err_probe for admv4420 and ad9523
Subsystems (2)
v2 cover iio: frequency: use dev_err_probe for admv4420 and ad9523
Use dev_err_probe() instead of dev_err() in the probe paths of the admv4420 and ad9523 frequency drivers.
Each driver update is split into two patches:
- First patch introduces a local struct device variable in the probe function and replaces &spi->dev references in non-error paths.
- Second patch converts dev_err() calls to dev_err_probe() in the probe path.
No lines are edited twice across patch pairs.
Changes in v2:
- Fix vco_freq_hz format specifier from %lld to %llu (patch 2)
- Split pdata declaration and assignment in ad9523_probe() (patch 3)
- Leave dev_err(&spi->dev, ...) untouched in patch 3, let patch 4 handle the full dev_err_probe(dev, ...) conversion
Antoniu Miclaus (4):
iio: frequency: admv4420: add dev variable
iio: frequency: admv4420: use dev_err_probe
iio: frequency: ad9523: add dev variable
iio: frequency: ad9523: use dev_err_probe
drivers/iio/frequency/ad9523.c | 22 ++++++++++---------- drivers/iio/frequency/admv4420.c | 35 +++++++++++++++----------------- 2 files changed, 27 insertions(+), 30 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 2/4 iio: frequency: admv4420: use dev_err_probe
Use dev_err_probe() instead of dev_err() in the probe path to ensure proper handling of deferred probing and to simplify error handling.
Also fix the format specifier for vco_freq_hz from %lld to %llu since it is u64 (unsigned), and add missing newline to the error message.
---
Changes in v2:
- Fix vco_freq_hz format specifier from %lld to %llu
- Add missing newline to error message
drivers/iio/frequency/admv4420.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/iio/frequency/admv4420.c +12 -16
@@ -279,10 +279,9 @@ static int admv4420_setup(struct iio_dev *indio_dev)if (ret)return ret; -if (val !=ADMV4420_SCRATCH_PAD_VAL_1 ) { -dev_err (dev,"Failed ADMV4420 to read/write scratchpad %x " , val); -return -EIO ; - } +if (val !=ADMV4420_SCRATCH_PAD_VAL_1 ) +return dev_err_probe (dev, -EIO , +"Failed ADMV4420 to read/write scratchpad %x\n" , val); ret = regmap_write(st->regmap, ADMV4420_SCRATCHPAD,
@@ -294,10 +293,9 @@ static int admv4420_setup(struct iio_dev *indio_dev)if (ret)return ret; -if (val !=ADMV4420_SCRATCH_PAD_VAL_2 ) { -dev_err (dev,"Failed to read/write scratchpad %x " , val); -return -EIO ; - } +if (val !=ADMV4420_SCRATCH_PAD_VAL_2 ) +return dev_err_probe (dev, -EIO , +"Failed to read/write scratchpad %x\n" , val); st->mux_sel =ADMV4420_LOCK_DTCT ; st->lo_freq_hz =ADMV4420_DEFAULT_LO_FREQ_HZ ;
@@ -305,10 +303,10 @@ static int admv4420_setup(struct iio_dev *indio_dev)admv4420_fw_parse (st); ret =admv4420_calc_parameters (st); -if (ret) { -dev_err (dev,"Failed calc parameters for %lld " , st->vco_freq_hz); -return ret; - } +if (ret) +return dev_err_probe (dev, ret, +"Failed calc parameters for %llu\n" , + st->vco_freq_hz); ret =regmap_write (st->regmap,ADMV4420_R_DIV_L ,FIELD_GET (0xFF , st->ref_block.divider));
@@ -369,10 +367,8 @@ static int admv4420_probe(struct spi_device *spi) indio_dev->num_channels =ARRAY_SIZE (admv4420_channels); ret =admv4420_setup (indio_dev); -if (ret) { -dev_err (&spi->dev,"Setup ADMV4420 failed (%d)\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Setup ADMV4420 failed\n" );return devm_iio_device_register (dev, indio_dev); }
Signature · 1 line
2.43.0
PATCH v2 3/4 iio: frequency: ad9523: add dev variable
In reply to Antoniu MiclausIntroduce 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.
---
Changes in v2:
- Split pdata declaration and assignment
- Leave dev_err(&spi->dev, ...) untouched, let patch 4 handle the full dev_err_probe(dev, ...) conversion
drivers/iio/frequency/ad9523.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/iio/frequency/ad9523.c +9 -7
@@ -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[] = {
Signature · 1 line
2.43.0
PATCH v2 4/4 iio: frequency: ad9523: use dev_err_probe
In reply to Antoniu MiclausUse dev_err_probe() instead of dev_err() in the probe path to ensure proper handling of deferred probing and to simplify error handling.
---
Changes in v2:
- No changes
drivers/iio/frequency/ad9523.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/frequency/ad9523.c +2 -4
@@ -955,10 +955,8 @@ static int ad9523_probe(struct spi_device *spi)int ret; pdata =dev_get_platdata (dev); -if (!pdata) { -dev_err (&spi->dev,"no platform data?\n" ); -return -EINVAL ; - } +if (!pdata) +return dev_err_probe (dev, -EINVAL ,"no platform data?\n" ); indio_dev =devm_iio_device_alloc (dev,sizeof (*st));if (indio_dev ==NULL )
Signature · 1 line
2.43.0
PATCH v2 1/4 iio: frequency: admv4420: add dev variable
In reply to Antoniu MiclausIntroduce a local struct device variable in admv4420_probe() to simplify subsequent conversions and improve code readability.
No functional change.
---
Changes in v2:
- No changes
drivers/iio/frequency/admv4420.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/iio/frequency/admv4420.c +4 -3
@@ -344,18 +344,19 @@ static int admv4420_setup(struct iio_dev *indio_dev)static int admv4420_probe (struct spi_device *spi) { +struct device *dev = &spi->dev;struct iio_dev *indio_dev;struct admv4420_state *st;struct regmap *regmap;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 ; regmap =devm_regmap_init_spi (spi, &admv4420_regmap_config);if (IS_ERR (regmap)) -return dev_err_probe (&spi->dev,PTR_ERR (regmap), +return dev_err_probe (dev,PTR_ERR (regmap),"Failed to initializing spi regmap\n" ); st =iio_priv (indio_dev);
@@ -373,7 +374,7 @@ static int admv4420_probe(struct spi_device *spi)return ret; } -return devm_iio_device_register (&spi->dev, indio_dev); +return devm_iio_device_register (dev, indio_dev); }static const struct of_device_id admv4420_of_match[] = {
Signature · 1 line
2.43.0
Re: [PATCH v2 3/4] iio: frequency: ad9523: add dev variable
In reply to Antoniu MiclausQuoted 7 lines · Antoniu Miclaus
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe
In reply to Antoniu MiclausQuoted 2 lines · Antoniu Miclaus
Use
dev_err_probe()instead ofdev_err()in the probe path to ensure proper handling of deferred probing and to simplify error handling.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 10 lines · On Fri, 13 Mar 2026 13:57:40 +0200 Antoniu Miclaus…
Use
dev_err_probe()instead ofdev_err()in the probe paths of the admv4420 and ad9523 frequency drivers.Each driver update is split into two patches:
- First patch introduces a local struct device variable in the probe function and replaces&spi->devreferences in non-error paths.
- Second patch convertsdev_err()calls todev_err_probe()in the probe path.No lines are edited twice across patch pairs.
Series applied to the testing branch of iio.git.
Usual stuff about will wait for bots to poke it then push out as togreg for linux-next to pick it up.
thanks,
Jonathan
Quoted 17 lines
Changes in v2:
- Fixvco_freq_hzformat specifier from %lld to %llu (patch 2)
- Split pdata declaration and assignment inad9523_probe()(patch 3)
- Leavedev_err(&spi->dev, ...)untouched in patch 3, let patch 4 handle the fulldev_err_probe(dev, ...)conversionAntoniu Miclaus (4):
iio: frequency: admv4420: add dev variable
iio: frequency: admv4420: usedev_err_probe
iio: frequency: ad9523: add dev variable
iio: frequency: ad9523: usedev_err_probedrivers/iio/frequency/ad9523.c | 22 ++++++++++---------- drivers/iio/frequency/admv4420.c | 35 +++++++++++++++----------------- 2 files changed, 27 insertions(+), 30 deletions(-)