public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523
@ 2026-03-13 11:57 Antoniu Miclaus
  2026-03-13 11:57 ` [PATCH v2 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Antoniu Miclaus @ 2026-03-13 11:57 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.

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(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/4] iio: frequency: admv4420: add dev variable
  2026-03-13 11:57 [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
@ 2026-03-13 11:57 ` Antoniu Miclaus
  2026-03-13 11:57 ` [PATCH v2 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Antoniu Miclaus @ 2026-03-13 11:57 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel
  Cc: Antoniu Miclaus, Andy Shevchenko

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>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
Changes in v2:
  - No changes

 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] 8+ messages in thread

* [PATCH v2 2/4] iio: frequency: admv4420: use dev_err_probe
  2026-03-13 11:57 [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
  2026-03-13 11:57 ` [PATCH v2 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
@ 2026-03-13 11:57 ` Antoniu Miclaus
  2026-03-13 11:57 ` [PATCH v2 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Antoniu Miclaus @ 2026-03-13 11:57 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel
  Cc: Antoniu Miclaus, Andy Shevchenko

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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
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(-)

diff --git a/drivers/iio/frequency/admv4420.c b/drivers/iio/frequency/admv4420.c
index 6ebfe08fc211..618511eddfb1 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,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);
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/4] iio: frequency: ad9523: add dev variable
  2026-03-13 11:57 [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
  2026-03-13 11:57 ` [PATCH v2 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
  2026-03-13 11:57 ` [PATCH v2 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
@ 2026-03-13 11:57 ` Antoniu Miclaus
  2026-03-13 14:10   ` Andy Shevchenko
  2026-03-13 11:57 ` [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
  2026-03-21 21:13 ` [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Jonathan Cameron
  4 siblings, 1 reply; 8+ messages in thread
From: Antoniu Miclaus @ 2026-03-13 11:57 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.

Split pdata declaration and assignment since the result is validated
immediately after.

No functional change.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
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(-)

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe
  2026-03-13 11:57 [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
                   ` (2 preceding siblings ...)
  2026-03-13 11:57 ` [PATCH v2 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
@ 2026-03-13 11:57 ` Antoniu Miclaus
  2026-03-13 14:11   ` Andy Shevchenko
  2026-03-21 21:13 ` [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Jonathan Cameron
  4 siblings, 1 reply; 8+ messages in thread
From: Antoniu Miclaus @ 2026-03-13 11:57 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>
---
Changes in v2:
  - No changes

 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 f4e80ea0c6d2..ea4d2763564a 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -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)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/4] iio: frequency: ad9523: add dev variable
  2026-03-13 11:57 ` [PATCH v2 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
@ 2026-03-13 14:10   ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-03-13 14:10 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 13, 2026 at 01:57:43PM +0200, Antoniu Miclaus wrote:
> 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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe
  2026-03-13 11:57 ` [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
@ 2026-03-13 14:11   ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-03-13 14:11 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 13, 2026 at 01:57:44PM +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>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523
  2026-03-13 11:57 [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
                   ` (3 preceding siblings ...)
  2026-03-13 11:57 ` [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
@ 2026-03-21 21:13 ` Jonathan Cameron
  4 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-03-21 21:13 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Lars-Peter Clausen, Michael Hennerich, David Lechner,
	Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

On Fri, 13 Mar 2026 13:57:40 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:

> 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.
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
> 
> 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(-)
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-21 21:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 11:57 [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Antoniu Miclaus
2026-03-13 11:57 ` [PATCH v2 1/4] iio: frequency: admv4420: add dev variable Antoniu Miclaus
2026-03-13 11:57 ` [PATCH v2 2/4] iio: frequency: admv4420: use dev_err_probe Antoniu Miclaus
2026-03-13 11:57 ` [PATCH v2 3/4] iio: frequency: ad9523: add dev variable Antoniu Miclaus
2026-03-13 14:10   ` Andy Shevchenko
2026-03-13 11:57 ` [PATCH v2 4/4] iio: frequency: ad9523: use dev_err_probe Antoniu Miclaus
2026-03-13 14:11   ` Andy Shevchenko
2026-03-21 21:13 ` [PATCH v2 0/4] iio: frequency: use dev_err_probe for admv4420 and ad9523 Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox