Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] staging: iio: ad9834: fix probe error handling and comment typo
@ 2026-05-02  2:18 Angus Gardner
  2026-05-02 19:54 ` Maxwell Doose
  0 siblings, 1 reply; 4+ messages in thread
From: Angus Gardner @ 2026-05-02  2:18 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-staging, gregkh, jic23, lars, Michael.Hennerich

Use dev_err_probe() for the master clock error path instead of open-coding
dev_err() + PTR_ERR(), consistent with the avdd regulator error path above
it and with the equivalent driver ad9832.c.

Simplify the -ENOMEM return after devm_iio_device_alloc() to a direct
return rather than bouncing through a local variable.

Fix a copy-paste typo in two comments that referred to 'AD9843' instead
of the correct chip name 'AD9834'.

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

diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index bdb2580e29bf..5968aca74ecf 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;
 			}
@@ -389,17 +389,14 @@ 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);
-	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;
-- 
2.51.0


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

* Re: [PATCH] staging: iio: ad9834: fix probe error handling and comment typo
  2026-05-02  2:18 [PATCH] staging: iio: ad9834: fix probe error handling and comment typo Angus Gardner
@ 2026-05-02 19:54 ` Maxwell Doose
  2026-05-03  8:53   ` Joshua Crofts
  0 siblings, 1 reply; 4+ messages in thread
From: Maxwell Doose @ 2026-05-02 19:54 UTC (permalink / raw)
  To: Angus Gardner, linux-iio
  Cc: linux-staging, gregkh, jic23, lars, Michael.Hennerich

Hi Angus,

On Fri May 1, 2026 at 9:18 PM CDT, Angus Gardner <angusg778@gmail.com> wrote:
> Use dev_err_probe() for the master clock error path instead of open-coding
> dev_err() + PTR_ERR(), consistent with the avdd regulator error path above
> it and with the equivalent driver ad9832.c.
>
> Simplify the -ENOMEM return after devm_iio_device_alloc() to a direct
> return rather than bouncing through a local variable.
>
> Fix a copy-paste typo in two comments that referred to 'AD9843' instead
> of the correct chip name 'AD9834'.
>
> Signed-off-by: Angus Gardner <angusg778@gmail.com>
> ---
>  drivers/staging/iio/frequency/ad9834.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
>

Patch itself looks good but maybe rephrase subject to say "Use probe
error handling and fix comment typo" instead? "Fix" seems a bit generic
for my tastes, and we're not really fixing anything anyways.

I'm not the final authority on naming so its at the discretion of
either Andy or Jonathan, and maybe Greg. So either way,
Reviewed-by: Maxwell Doose <m32285159@gmail.com>

best regards,
maxwell

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

* Re: [PATCH] staging: iio: ad9834: fix probe error handling and comment typo
  2026-05-02 19:54 ` Maxwell Doose
@ 2026-05-03  8:53   ` Joshua Crofts
  2026-05-03 15:07     ` Maxwell Doose
  0 siblings, 1 reply; 4+ messages in thread
From: Joshua Crofts @ 2026-05-03  8:53 UTC (permalink / raw)
  To: Maxwell Doose
  Cc: Angus Gardner, linux-iio, linux-staging, gregkh, jic23, lars,
	Michael.Hennerich

On Sat, 2 May 2026 at 21:54, Maxwell Doose <m32285159@gmail.com> wrote:
>
> Hi Angus,
>
> On Fri May 1, 2026 at 9:18 PM CDT, Angus Gardner <angusg778@gmail.com> wrote:
> > Use dev_err_probe() for the master clock error path instead of open-coding
> > dev_err() + PTR_ERR(), consistent with the avdd regulator error path above
> > it and with the equivalent driver ad9832.c.

I found another dev_err() call in the same function, maybe change this one also?
https://elixir.bootlin.com/linux/v7.0.1/source/drivers/staging/iio/frequency/ad9834.c#L452

> > Simplify the -ENOMEM return after devm_iio_device_alloc() to a direct
> > return rather than bouncing through a local variable.
> >
> > Fix a copy-paste typo in two comments that referred to 'AD9843' instead
> > of the correct chip name 'AD9834'.
> >
> > Signed-off-by: Angus Gardner <angusg778@gmail.com>
> > ---
> >  drivers/staging/iio/frequency/ad9834.c | 17 +++++++----------
> >  1 file changed, 7 insertions(+), 10 deletions(-)
> >
>
> Patch itself looks good but maybe rephrase subject to say "Use probe
> error handling and fix comment typo" instead? "Fix" seems a bit generic
> for my tastes, and we're not really fixing anything anyways.
>
> I'm not the final authority on naming so its at the discretion of
> either Andy or Jonathan, and maybe Greg. So either way,
> Reviewed-by: Maxwell Doose <m32285159@gmail.com>

You're mixing different logical changes into one patch, therefore it's
harder to review and harder to keep track of the changes after merging
(e.g. running git blame). Instead, you should have a series (named
something like "ad9834: driver cleanup") and three patches under it:
1. simplify -ENOMEM errno return
2. use dev_err_probe()
3. fix typos in comments

-- 
Kind regards

CJD

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

* Re: [PATCH] staging: iio: ad9834: fix probe error handling and comment typo
  2026-05-03  8:53   ` Joshua Crofts
@ 2026-05-03 15:07     ` Maxwell Doose
  0 siblings, 0 replies; 4+ messages in thread
From: Maxwell Doose @ 2026-05-03 15:07 UTC (permalink / raw)
  To: Joshua Crofts, Maxwell Doose
  Cc: Angus Gardner, linux-iio, linux-staging, gregkh, jic23, lars,
	Michael.Hennerich

On Sun May 3, 2026 at 3:53 AM CDT, Joshua Crofts wrote:
> On Sat, 2 May 2026 at 21:54, Maxwell Doose <m32285159@gmail.com> wrote:
>>
>> Hi Angus,
>>
>> On Fri May 1, 2026 at 9:18 PM CDT, Angus Gardner <angusg778@gmail.com> wrote:
>> > Use dev_err_probe() for the master clock error path instead of open-coding
>> > dev_err() + PTR_ERR(), consistent with the avdd regulator error path above
>> > it and with the equivalent driver ad9832.c.
>
> I found another dev_err() call in the same function, maybe change this one also?
> https://elixir.bootlin.com/linux/v7.0.1/source/drivers/staging/iio/frequency/ad9834.c#L452
>

Shoot, I seem to have missed that in my review. Nice catch.

>
>> > Simplify the -ENOMEM return after devm_iio_device_alloc() to a direct
>> > return rather than bouncing through a local variable.
>> >
>> > Fix a copy-paste typo in two comments that referred to 'AD9843' instead
>> > of the correct chip name 'AD9834'.
>> >
>> > Signed-off-by: Angus Gardner <angusg778@gmail.com>
>> > ---
>> >  drivers/staging/iio/frequency/ad9834.c | 17 +++++++----------
>> >  1 file changed, 7 insertions(+), 10 deletions(-)
>> >
>>
>> Patch itself looks good but maybe rephrase subject to say "Use probe
>> error handling and fix comment typo" instead? "Fix" seems a bit generic
>> for my tastes, and we're not really fixing anything anyways.
>>
>> I'm not the final authority on naming so its at the discretion of
>> either Andy or Jonathan, and maybe Greg. So either way,
>> Reviewed-by: Maxwell Doose <m32285159@gmail.com>
>
> You're mixing different logical changes into one patch, therefore it's
> harder to review and harder to keep track of the changes after merging
> (e.g. running git blame). Instead, you should have a series (named
> something like "ad9834: driver cleanup") and three patches under it:
> 1. simplify -ENOMEM errno return
> 2. use dev_err_probe()
> 3. fix typos in comments
>

Of course this is undeniable but I think the other changes are so
miniscule that it wouldn't matter as much, but that's just my personal
opinion. Angus, you should probably split this into a patch series.

Either way, I still stand by my reviewed-by, at least based on technical
correctness, but make sure you at least add the missing dev_err_probe()
call that Joshua wanted Angus :)

best regards,
maxwell


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

end of thread, other threads:[~2026-05-03 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-02  2:18 [PATCH] staging: iio: ad9834: fix probe error handling and comment typo Angus Gardner
2026-05-02 19:54 ` Maxwell Doose
2026-05-03  8:53   ` Joshua Crofts
2026-05-03 15:07     ` Maxwell Doose

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