staging: iio: ad9834: driver cleanup
Subsystems (4)
v2 cover staging: iio: ad9834: driver cleanup
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/[email protected]/
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(-)
Signature · 1 line
2.51.0
PATCH v2 1/3 staging: iio: ad9834: simplify -ENOMEM return in probe
devm_iio_device_alloc() failure returns -ENOMEM via a local variable unnecessarily. Return -ENOMEM directly instead.
--- drivers/staging/iio/frequency/ad9834.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/iio/frequency/ad9834.c +2 -4
@@ -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 );
Signature · 1 line
2.51.0
Re: [PATCH 1/3] staging: iio: ad9834: simplify -ENOMEM return in probe
Quoted 9 lines · Angus Gardner
devm_iio_device_alloc()failure returns-ENOMEMvia a local variable unnecessarily. Return-ENOMEMdirectly instead.Signed-off-by Angus Gardner <[email protected]>--- drivers/staging/iio/frequency/ad9834.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
[snip]
Looks good to me.
best regards,
maxwell
PATCH v2 2/3 staging: iio: ad9834: use dev_err_probe() in probe function
In reply to Angus GardnerReplace 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().
--- drivers/staging/iio/frequency/ad9834.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/staging/iio/frequency/ad9834.c +6 -8
@@ -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)
Signature · 1 line
2.51.0
PATCH v2 3/3 staging: iio: ad9834: fix chip name typo in comments
In reply to Angus GardnerTwo comments incorrectly refer to 'AD9843' instead of 'AD9834'. Fix the copy-paste typo.
--- drivers/staging/iio/frequency/ad9834.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9834.c +2 -2
@@ -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 ; }
Signature · 1 line
2.51.0
Re: [PATCH 3/3] staging: iio: ad9834: fix chip name typo in comments
Quoted 9 lines · Angus Gardner
Two comments incorrectly refer to 'AD9843' instead of 'AD9834'. Fix the copy-paste typo.
Signed-off-by Angus Gardner <[email protected]>--- drivers/staging/iio/frequency/ad9834.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
[snip]
Looks good to me.
best regards,
maxwell
Jonathan Cameron
maintainerQuoted 5 lines · On Mon, 4 May 2026 19:20:56 +1000 Angus Gardner <[email protected]> wrote:
v2: Split into a series of three patches as suggested by reviewer feedback.
Also add a missingdev_err_probe()conversion for the SPI init error path pointed out by Joshua.v1: https://lore.kernel.org/linux-staging/[email protected]/
Hi Angus
Series looks good to me (Thanks Maxwell and Joshua for reviewing!)
Applied to the testing branch of iio.git.
Quoted 9 lines
Angus Gardner (3):
staging: iio: ad9834: simplify-ENOMEMreturn in probe
staging: iio: ad9834: usedev_err_probe()in probe function
staging: iio: ad9834: fix chip name typo in commentsdrivers/staging/iio/frequency/ad9834.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
Quoted 8 lines · Jonathan Cameron
Quoted 4 lines · On Mon, 4 May 2026 19:20:56 +1000 Angus Gardner <[email protected]> wrote:
v2: Split into a series of three patches as suggested by reviewer feedback.
Also add a missingdev_err_probe()conversion for the SPI init error path pointed out by Joshua.
Quoted 7 lines
Quoted 1 line
v1: https://lore.kernel.org/linux-staging/[email protected]/
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)
Jonathan Cameron
maintainerQuoted 14 lines · On Mon, 4 May 2026 11:10:27 -0500 Maxwell Doose <[email protected]> wrote:
Quoted 13 lines · Jonathan Cameron
Quoted 5 lines · On Mon, 4 May 2026 19:20:56 +1000 Angus Gardner <[email protected]> wrote:
v2: Split into a series of three patches as suggested by reviewer feedback.
Also add a missingdev_err_probe()conversion for the SPI init error path pointed out by Joshua.v1: https://lore.kernel.org/linux-staging/[email protected]/
Hi Angus
Series looks good to me (Thanks Maxwell and Joshua for reviewing!)
Quoted 7 lines
Quoted 2 lines
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
Quoted 6 lines
best regards,
maxwell(p.s., feel free to call me Max, cheers)