Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] staging: iio: ad9834: driver cleanup
@ 2026-05-04  9:20 Angus Gardner
  2026-05-04  9:20 ` [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe Angus Gardner
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Angus Gardner @ 2026-05-04  9:20 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-staging, gregkh, jic23, lars, Michael.Hennerich

v2: Split into a series of three patches as suggested by reviewer feedback.
    Also add a missing dev_err_probe() conversion for the SPI init error
    path pointed out by Joshua.

v1: https://lore.kernel.org/linux-staging/20260502021815.3953423-1-angusg778@gmail.com/

Angus Gardner (3):
  staging: iio: ad9834: simplify -ENOMEM return in probe
  staging: iio: ad9834: use dev_err_probe() in probe function
  staging: iio: ad9834: fix chip name typo in comments

 drivers/staging/iio/frequency/ad9834.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

-- 
2.51.0


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

* [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe
  2026-05-04  9:20 [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Angus Gardner
@ 2026-05-04  9:20 ` Angus Gardner
  2026-05-04 12:37   ` Maxwell Doose
  2026-05-04  9:20 ` [PATCH 2/3] staging: iio: ad9834: use dev_err_probe() in probe function Angus Gardner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Angus Gardner @ 2026-05-04  9:20 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-staging, gregkh, jic23, lars, Michael.Hennerich

devm_iio_device_alloc() failure returns -ENOMEM via a local variable
unnecessarily. Return -ENOMEM directly instead.

Signed-off-by: Angus Gardner <angusg778@gmail.com>
---
 drivers/staging/iio/frequency/ad9834.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index bdb2580e29bf..f2bf7123ffcf 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -389,10 +389,8 @@ static int ad9834_probe(struct spi_device *spi)
 		return dev_err_probe(&spi->dev, ret, "Failed to enable specified AVDD supply\n");
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (!indio_dev) {
-		ret = -ENOMEM;
-		return ret;
-	}
+	if (!indio_dev)
+		return -ENOMEM;
 	st = iio_priv(indio_dev);
 	mutex_init(&st->lock);
 	st->mclk = devm_clk_get_enabled(&spi->dev, NULL);
-- 
2.51.0


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

* [PATCH 2/3] staging: iio: ad9834: use dev_err_probe() in probe function
  2026-05-04  9:20 [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Angus Gardner
  2026-05-04  9:20 ` [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe Angus Gardner
@ 2026-05-04  9:20 ` Angus Gardner
  2026-05-04  9:20 ` [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments Angus Gardner
  2026-05-04 15:23 ` [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Jonathan Cameron
  3 siblings, 0 replies; 9+ messages in thread
From: Angus Gardner @ 2026-05-04  9:20 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-staging, gregkh, jic23, lars, Michael.Hennerich

Replace open-coded dev_err() + return sequences with dev_err_probe(),
which is the preferred pattern for probe error paths as it handles
deferred probing correctly and reduces boilerplate.

Convert all three remaining instances in ad9834_probe():
 - master clock enable failure
 - device init SPI sync failure

The avdd regulator path already used dev_err_probe().

Signed-off-by: Angus Gardner <angusg778@gmail.com>
---
 drivers/staging/iio/frequency/ad9834.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index f2bf7123ffcf..0e4727fb8cde 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -394,10 +394,9 @@ static int ad9834_probe(struct spi_device *spi)
 	st = iio_priv(indio_dev);
 	mutex_init(&st->lock);
 	st->mclk = devm_clk_get_enabled(&spi->dev, NULL);
-	if (IS_ERR(st->mclk)) {
-		dev_err(&spi->dev, "Failed to enable master clock\n");
-		return PTR_ERR(st->mclk);
-	}
+	if (IS_ERR(st->mclk))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->mclk),
+				     "Failed to enable master clock\n");
 
 	st->spi = spi;
 	st->devid = spi_get_device_id(spi)->driver_data;
@@ -439,10 +438,9 @@ static int ad9834_probe(struct spi_device *spi)
 
 	st->data = cpu_to_be16(AD9834_REG_CMD | st->control);
 	ret = spi_sync(st->spi, &st->msg);
-	if (ret) {
-		dev_err(&spi->dev, "device init failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&spi->dev, ret,
+				     "device init failed\n");
 
 	ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, 1000000);
 	if (ret)
-- 
2.51.0


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

* [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments
  2026-05-04  9:20 [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Angus Gardner
  2026-05-04  9:20 ` [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe Angus Gardner
  2026-05-04  9:20 ` [PATCH 2/3] staging: iio: ad9834: use dev_err_probe() in probe function Angus Gardner
@ 2026-05-04  9:20 ` Angus Gardner
  2026-05-04 12:33   ` Maxwell Doose
  2026-05-04 15:23 ` [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Jonathan Cameron
  3 siblings, 1 reply; 9+ messages in thread
From: Angus Gardner @ 2026-05-04  9:20 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-staging, gregkh, jic23, lars, Michael.Hennerich

Two comments incorrectly refer to 'AD9843' instead of 'AD9834'.
Fix the copy-paste typo.

Signed-off-by: Angus Gardner <angusg778@gmail.com>
---
 drivers/staging/iio/frequency/ad9834.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 0e4727fb8cde..a27c03387526 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -164,7 +164,7 @@ static ssize_t ad9834_write(struct device *dev,
 		break;
 	case AD9834_OPBITEN:
 		if (st->control & AD9834_MODE) {
-			ret = -EINVAL;  /* AD9843 reserved mode */
+			ret = -EINVAL;  /* AD9834 reserved mode */
 			break;
 		}
 
@@ -239,7 +239,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
 				st->control &= ~AD9834_OPBITEN;
 				st->control |= AD9834_MODE;
 			} else if (st->control & AD9834_OPBITEN) {
-				ret = -EINVAL;	/* AD9843 reserved mode */
+				ret = -EINVAL;	/* AD9834 reserved mode */
 			} else {
 				st->control |= AD9834_MODE;
 			}
-- 
2.51.0


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

* Re: [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments
  2026-05-04  9:20 ` [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments Angus Gardner
@ 2026-05-04 12:33   ` Maxwell Doose
  0 siblings, 0 replies; 9+ messages in thread
From: Maxwell Doose @ 2026-05-04 12:33 UTC (permalink / raw)
  To: Angus Gardner
  Cc: linux-iio, linux-staging, gregkh, jic23, lars, Michael.Hennerich

On Mon, May 4, 2026 at 4:21 AM Angus Gardner <angusg778@gmail.com> wrote:
>
> Two comments incorrectly refer to 'AD9843' instead of 'AD9834'.
> Fix the copy-paste typo.
>
> Signed-off-by: Angus Gardner <angusg778@gmail.com>
> ---
>  drivers/staging/iio/frequency/ad9834.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
[snip]

Looks good to me.
Reviewed-by: Maxwell Doose <m32285159@gmail.com>

best regards,
maxwell

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

* Re: [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe
  2026-05-04  9:20 ` [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe Angus Gardner
@ 2026-05-04 12:37   ` Maxwell Doose
  0 siblings, 0 replies; 9+ messages in thread
From: Maxwell Doose @ 2026-05-04 12:37 UTC (permalink / raw)
  To: Angus Gardner
  Cc: linux-iio, linux-staging, gregkh, jic23, lars, Michael.Hennerich

On Mon, May 4, 2026 at 4:22 AM Angus Gardner <angusg778@gmail.com> wrote:
>
> devm_iio_device_alloc() failure returns -ENOMEM via a local variable
> unnecessarily. Return -ENOMEM directly instead.
>
> Signed-off-by: Angus Gardner <angusg778@gmail.com>
> ---
>  drivers/staging/iio/frequency/ad9834.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
[snip]

Looks good to me.
Reviewed-by: Maxwell Doose <m32285159@gmail.com>

best regards,
maxwell

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

* Re: [PATCH v2 0/3] staging: iio: ad9834: driver cleanup
  2026-05-04  9:20 [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Angus Gardner
                   ` (2 preceding siblings ...)
  2026-05-04  9:20 ` [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments Angus Gardner
@ 2026-05-04 15:23 ` Jonathan Cameron
  2026-05-04 16:10   ` Maxwell Doose
  3 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2026-05-04 15:23 UTC (permalink / raw)
  To: Angus Gardner; +Cc: linux-iio, linux-staging, gregkh, lars, Michael.Hennerich

On Mon,  4 May 2026 19:20:56 +1000
Angus Gardner <angusg778@gmail.com> wrote:

> v2: Split into a series of three patches as suggested by reviewer feedback.
>     Also add a missing dev_err_probe() conversion for the SPI init error
>     path pointed out by Joshua.
> 
> v1: https://lore.kernel.org/linux-staging/20260502021815.3953423-1-angusg778@gmail.com/
Hi Angus

Series looks good to me (Thanks Maxwell and Joshua for reviewing!)

Applied to the testing branch of iio.git.

> 
> Angus Gardner (3):
>   staging: iio: ad9834: simplify -ENOMEM return in probe
>   staging: iio: ad9834: use dev_err_probe() in probe function
>   staging: iio: ad9834: fix chip name typo in comments
> 
>  drivers/staging/iio/frequency/ad9834.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 


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

* Re: [PATCH v2 0/3] staging: iio: ad9834: driver cleanup
  2026-05-04 15:23 ` [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Jonathan Cameron
@ 2026-05-04 16:10   ` Maxwell Doose
  2026-05-04 16:54     ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Maxwell Doose @ 2026-05-04 16:10 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Angus Gardner, linux-iio, linux-staging, gregkh, lars,
	Michael.Hennerich

On Mon, May 4, 2026 at 10:23 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Mon,  4 May 2026 19:20:56 +1000
> Angus Gardner <angusg778@gmail.com> wrote:
>
> > v2: Split into a series of three patches as suggested by reviewer feedback.
> >     Also add a missing dev_err_probe() conversion for the SPI init error
> >     path pointed out by Joshua.
> >
> > v1: https://lore.kernel.org/linux-staging/20260502021815.3953423-1-angusg778@gmail.com/
> Hi Angus
>
> Series looks good to me (Thanks Maxwell and Joshua for reviewing!)
>
> Applied to the testing branch of iio.git.
>

I realized I forgot to add my explicit reviewed-by to the v2 of the
"use dev_err_probe() in probe function" patch. If it's not too much
trouble, could I get my reviewed-by tag added to that patch? If not
then no worries.

best regards,
maxwell

(p.s., feel free to call me Max, cheers)

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

* Re: [PATCH v2 0/3] staging: iio: ad9834: driver cleanup
  2026-05-04 16:10   ` Maxwell Doose
@ 2026-05-04 16:54     ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2026-05-04 16:54 UTC (permalink / raw)
  To: Maxwell Doose
  Cc: Angus Gardner, linux-iio, linux-staging, gregkh, lars,
	Michael.Hennerich

On Mon, 4 May 2026 11:10:27 -0500
Maxwell Doose <m32285159@gmail.com> wrote:

> On Mon, May 4, 2026 at 10:23 AM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Mon,  4 May 2026 19:20:56 +1000
> > Angus Gardner <angusg778@gmail.com> wrote:
> >  
> > > v2: Split into a series of three patches as suggested by reviewer feedback.
> > >     Also add a missing dev_err_probe() conversion for the SPI init error
> > >     path pointed out by Joshua.
> > >
> > > v1: https://lore.kernel.org/linux-staging/20260502021815.3953423-1-angusg778@gmail.com/  
> > Hi Angus
> >
> > Series looks good to me (Thanks Maxwell and Joshua for reviewing!)
> >
> > Applied to the testing branch of iio.git.
> >  
> 
> I realized I forgot to add my explicit reviewed-by to the v2 of the
> "use dev_err_probe() in probe function" patch. If it's not too much
> trouble, could I get my reviewed-by tag added to that patch? If not
> then no worries.

Added.

Thanks again Max!

Jonathan

> 
> best regards,
> maxwell
> 
> (p.s., feel free to call me Max, cheers)
> 


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

end of thread, other threads:[~2026-05-04 16:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04  9:20 [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Angus Gardner
2026-05-04  9:20 ` [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe Angus Gardner
2026-05-04 12:37   ` Maxwell Doose
2026-05-04  9:20 ` [PATCH 2/3] staging: iio: ad9834: use dev_err_probe() in probe function Angus Gardner
2026-05-04  9:20 ` [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments Angus Gardner
2026-05-04 12:33   ` Maxwell Doose
2026-05-04 15:23 ` [PATCH v2 0/3] staging: iio: ad9834: driver cleanup Jonathan Cameron
2026-05-04 16:10   ` Maxwell Doose
2026-05-04 16:54     ` Jonathan Cameron

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