* [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523
@ 2026-03-06 10:24 Antoniu Miclaus
2026-03-06 10:24 ` [PATCH 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Antoniu Miclaus @ 2026-03-06 10:24 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
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.
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 | 21 ++++++++++----------
drivers/iio/frequency/admv4420.c | 34 ++++++++++++++------------------
2 files changed, 25 insertions(+), 30 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/4] iio: frequency: admv4420: add dev variable
2026-03-06 10:24 [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
@ 2026-03-06 10:24 ` Antoniu Miclaus
2026-03-06 14:41 ` Andy Shevchenko
2026-03-06 10:24 ` [PATCH 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Antoniu Miclaus @ 2026-03-06 10:24 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Introduce a local struct device variable in admv4420_probe() to
simplify subsequent conversions and improve code readability.
No functional change.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/frequency/admv4420.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/frequency/admv4420.c b/drivers/iio/frequency/admv4420.c
index 8748d9747639..6ebfe08fc211 100644
--- a/drivers/iio/frequency/admv4420.c
+++ b/drivers/iio/frequency/admv4420.c
@@ -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[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] iio: frequency: admv4420: use dev_err_probe
2026-03-06 10:24 [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
2026-03-06 10:24 ` [PATCH 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
@ 2026-03-06 10:24 ` Antoniu Miclaus
2026-03-06 14:45 ` Andy Shevchenko
2026-03-06 10:24 ` [PATCH 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Antoniu Miclaus @ 2026-03-06 10:24 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Use dev_err_probe() instead of dev_err() in the probe path to ensure
proper handling of deferred probing and to simplify error handling.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/frequency/admv4420.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/frequency/admv4420.c b/drivers/iio/frequency/admv4420.c
index 6ebfe08fc211..2416fe850ecf 100644
--- a/drivers/iio/frequency/admv4420.c
+++ b/drivers/iio/frequency/admv4420.c
@@ -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,9 @@ 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 %lld\n", st->vco_freq_hz);
ret = regmap_write(st->regmap, ADMV4420_R_DIV_L,
FIELD_GET(0xFF, st->ref_block.divider));
@@ -369,10 +366,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);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] iio: frequency: ad9523: add dev variable
2026-03-06 10:24 [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
2026-03-06 10:24 ` [PATCH 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
2026-03-06 10:24 ` [PATCH 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
@ 2026-03-06 10:24 ` Antoniu Miclaus
2026-03-06 14:39 ` Andy Shevchenko
2026-03-06 10:24 ` [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
2026-03-06 12:24 ` [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Andy Shevchenko
4 siblings, 1 reply; 11+ messages in thread
From: Antoniu Miclaus @ 2026-03-06 10:24 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Introduce a local struct device variable in ad9523_probe() to simplify
subsequent conversions and improve code readability.
No functional change.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/frequency/ad9523.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index ad32eb66edca..6d15ec648280 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -948,17 +948,18 @@ 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 = dev_get_platdata(dev);
struct iio_dev *indio_dev;
struct ad9523_state *st;
int ret;
if (!pdata) {
- dev_err(&spi->dev, "no platform data?\n");
+ dev_err(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 +967,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 +986,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 +1006,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[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe
2026-03-06 10:24 [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
` (2 preceding siblings ...)
2026-03-06 10:24 ` [PATCH 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
@ 2026-03-06 10:24 ` Antoniu Miclaus
2026-03-06 12:24 ` Andy Shevchenko
2026-03-06 12:24 ` [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Andy Shevchenko
4 siblings, 1 reply; 11+ messages in thread
From: Antoniu Miclaus @ 2026-03-06 10:24 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Use dev_err_probe() instead of dev_err() in the probe path to ensure
proper handling of deferred probing and to simplify error handling.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/frequency/ad9523.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 6d15ec648280..f29a45837565 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -954,10 +954,8 @@ static int ad9523_probe(struct spi_device *spi)
struct ad9523_state *st;
int ret;
- if (!pdata) {
- dev_err(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)
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe
2026-03-06 10:24 ` [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
@ 2026-03-06 12:24 ` Andy Shevchenko
2026-03-07 11:09 ` Jonathan Cameron
0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2026-03-06 12:24 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, Mar 06, 2026 at 12:24:48PM +0200, Antoniu Miclaus wrote:
> Use dev_err_probe() instead of dev_err() in the probe path to ensure
> proper handling of deferred probing and to simplify error handling.
...
> - if (!pdata) {
> - dev_err(dev, "no platform data?\n");
> - return -EINVAL;
> - }
> + if (!pdata)
> + return dev_err_probe(dev, -EINVAL, "no platform data?\n");
Platform data?! Maybe we can get rid of it entirely?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523
2026-03-06 10:24 [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
` (3 preceding siblings ...)
2026-03-06 10:24 ` [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
@ 2026-03-06 12:24 ` Andy Shevchenko
4 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-03-06 12:24 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, Mar 06, 2026 at 12:24:44PM +0200, Antoniu Miclaus wrote:
> Use dev_err_probe() instead of dev_err() in the probe paths of the
> admv4420 and ad9523 frequency drivers.
In the subject you need to use () as well: dev_err_probe().
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/4] iio: frequency: ad9523: add dev variable
2026-03-06 10:24 ` [PATCH 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
@ 2026-03-06 14:39 ` Andy Shevchenko
0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-03-06 14:39 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, Mar 06, 2026 at 12:24:47PM +0200, Antoniu Miclaus wrote:
> Introduce a local struct device variable in ad9523_probe() to simplify
> subsequent conversions and improve code readability.
...
> 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 = dev_get_platdata(dev);
It's always better to split assignment and definition when the result is going
to be validated. It makes code robust against potential changes in
between that might alter that variable / value.
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");
> + dev_err(dev, "no platform data?\n");
This line can be updated in the second patch altogether.
> return -EINVAL;
> }
...
> - 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);
Side note: The material to move to reset-gpio driver instead (I think we have
tons of the IIO drivers with the same).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] iio: frequency: admv4420: add dev variable
2026-03-06 10:24 ` [PATCH 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
@ 2026-03-06 14:41 ` Andy Shevchenko
0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-03-06 14:41 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, Mar 06, 2026 at 12:24:45PM +0200, Antoniu Miclaus wrote:
> Introduce a local struct device variable in admv4420_probe() to
> simplify subsequent conversions and improve code readability.
>
> No functional change.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] iio: frequency: admv4420: use dev_err_probe
2026-03-06 10:24 ` [PATCH 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
@ 2026-03-06 14:45 ` Andy Shevchenko
0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-03-06 14:45 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, Mar 06, 2026 at 12:24:46PM +0200, Antoniu Miclaus wrote:
> Use dev_err_probe() instead of dev_err() in the probe path to ensure
> proper handling of deferred probing and to simplify error handling.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
After addressing the below.
...
> 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 %lld\n", st->vco_freq_hz);
Besides too long line, are you sure the lld is the proper specifier?
I.o.w. is it really signed long long? (It also adds missing '\n',
does it need to be mentioned in the commit message?)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe
2026-03-06 12:24 ` Andy Shevchenko
@ 2026-03-07 11:09 ` Jonathan Cameron
0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2026-03-07 11:09 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, 6 Mar 2026 14:24:25 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Mar 06, 2026 at 12:24:48PM +0200, Antoniu Miclaus wrote:
> > Use dev_err_probe() instead of dev_err() in the probe path to ensure
> > proper handling of deferred probing and to simplify error handling.
>
> ...
>
> > - if (!pdata) {
> > - dev_err(dev, "no platform data?\n");
> > - return -EINVAL;
> > - }
> > + if (!pdata)
> > + return dev_err_probe(dev, -EINVAL, "no platform data?\n");
>
> Platform data?! Maybe we can get rid of it entirely?
Good thing to do, but big job. There is no DT binding for this and
the platform data is very complex. I checked though and the part is
still recommended for new designs so if Analog wants to support it going
forward that work needs doing.
Jonathan
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-03-07 11:09 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-06 10:24 [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
2026-03-06 10:24 ` [PATCH 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
2026-03-06 14:41 ` Andy Shevchenko
2026-03-06 10:24 ` [PATCH 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
2026-03-06 14:45 ` Andy Shevchenko
2026-03-06 10:24 ` [PATCH 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
2026-03-06 14:39 ` Andy Shevchenko
2026-03-06 10:24 ` [PATCH 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
2026-03-06 12:24 ` Andy Shevchenko
2026-03-07 11:09 ` Jonathan Cameron
2026-03-06 12:24 ` [PATCH 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox