[PATCH 3/5] staging: iio: ad9832: cleanup dev_err_probe()

Tomas Borquez posted 5 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 3/5] staging: iio: ad9832: cleanup dev_err_probe()
Posted by Tomas Borquez 1 month, 3 weeks ago
Cleanup dev_err_probe() by keeping messages consistent and adding
error message for clock acquisition failure.

Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
---
 drivers/staging/iio/frequency/ad9832.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index f9ef3aede4..8d04f1b44f 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -302,15 +302,15 @@ static int ad9832_probe(struct spi_device *spi)
 
 	ret = devm_regulator_get_enable(&spi->dev, "avdd");
 	if (ret)
-		return dev_err_probe(&spi->dev, ret, "failed to enable specified AVDD voltage\n");
+		return dev_err_probe(&spi->dev, ret, "failed to enable AVDD supply\n");
 
 	ret = devm_regulator_get_enable(&spi->dev, "dvdd");
 	if (ret)
-		return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVDD supply\n");
+		return dev_err_probe(&spi->dev, ret, "failed to enable DVDD supply\n");
 
 	st->mclk = devm_clk_get_enabled(&spi->dev, "mclk");
 	if (IS_ERR(st->mclk))
-		return PTR_ERR(st->mclk);
+		return dev_err_probe(&spi->dev, PTR_ERR(st->mclk), "failed to enable MCLK\n");
 
 	st->spi = spi;
 	mutex_init(&st->lock);
-- 
2.43.0
Re: [PATCH 3/5] staging: iio: ad9832: cleanup dev_err_probe()
Posted by Marcelo Schmitt 1 month, 3 weeks ago
On 12/15, Tomas Borquez wrote:
> Cleanup dev_err_probe() by keeping messages consistent and adding
> error message for clock acquisition failure.

This is also a clean-up patch while patch 2 is a driver update so I would
provide this patch (currently patch 3) before the patch updating to use guard().

> 
> Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
> ---
>  drivers/staging/iio/frequency/ad9832.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> index f9ef3aede4..8d04f1b44f 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -302,15 +302,15 @@ static int ad9832_probe(struct spi_device *spi)
>  
>  	ret = devm_regulator_get_enable(&spi->dev, "avdd");
>  	if (ret)
> -		return dev_err_probe(&spi->dev, ret, "failed to enable specified AVDD voltage\n");
> +		return dev_err_probe(&spi->dev, ret, "failed to enable AVDD supply\n");
I'd break the lines and write the message in the line below for this and other
dev_err_probe() that exceed 80 columns. E.g.

		return dev_err_probe(&spi->dev, ret,
				     "failed to enable AVDD supply\n");

Note this is just a personal preference of mine, not enforced code style, so
fine if you prefer keep it as it is.

>  
>  	ret = devm_regulator_get_enable(&spi->dev, "dvdd");
>  	if (ret)
> -		return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVDD supply\n");
> +		return dev_err_probe(&spi->dev, ret, "failed to enable DVDD supply\n");
>  
>  	st->mclk = devm_clk_get_enabled(&spi->dev, "mclk");
>  	if (IS_ERR(st->mclk))
> -		return PTR_ERR(st->mclk);
> +		return dev_err_probe(&spi->dev, PTR_ERR(st->mclk), "failed to enable MCLK\n");
>  
>  	st->spi = spi;
>  	mutex_init(&st->lock);
> -- 
> 2.43.0
> 
>
Re: [PATCH 3/5] staging: iio: ad9832: cleanup dev_err_probe()
Posted by Jonathan Cameron 1 month, 2 weeks ago
On Thu, 18 Dec 2025 11:38:54 -0300
Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote:

> On 12/15, Tomas Borquez wrote:
> > Cleanup dev_err_probe() by keeping messages consistent and adding
> > error message for clock acquisition failure.  
> 
> This is also a clean-up patch while patch 2 is a driver update so I would
> provide this patch (currently patch 3) before the patch updating to use guard().
> 
There are a lot of &spi->dev in the probe function.  BEeore doing any of this
I'd suggest introducing a
struct device *dev = &spi->dev;
and replacing them all with dev.

That also shortens all the lines so maybe some return dev_err_probe()
end up below 80 chars and make the suggestion below irrelvant?
(I haven't checked!)

Jonathan

> > 
> > Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
> > ---
> >  drivers/staging/iio/frequency/ad9832.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> > index f9ef3aede4..8d04f1b44f 100644
> > --- a/drivers/staging/iio/frequency/ad9832.c
> > +++ b/drivers/staging/iio/frequency/ad9832.c
> > @@ -302,15 +302,15 @@ static int ad9832_probe(struct spi_device *spi)
> >  
> >  	ret = devm_regulator_get_enable(&spi->dev, "avdd");
> >  	if (ret)
> > -		return dev_err_probe(&spi->dev, ret, "failed to enable specified AVDD voltage\n");
> > +		return dev_err_probe(&spi->dev, ret, "failed to enable AVDD supply\n");  
> I'd break the lines and write the message in the line below for this and other
> dev_err_probe() that exceed 80 columns. E.g.
> 
> 		return dev_err_probe(&spi->dev, ret,
> 				     "failed to enable AVDD supply\n");
> 
> Note this is just a personal preference of mine, not enforced code style, so
> fine if you prefer keep it as it is.
> 
> >  
> >  	ret = devm_regulator_get_enable(&spi->dev, "dvdd");
> >  	if (ret)
> > -		return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVDD supply\n");
> > +		return dev_err_probe(&spi->dev, ret, "failed to enable DVDD supply\n");
> >  
> >  	st->mclk = devm_clk_get_enabled(&spi->dev, "mclk");
> >  	if (IS_ERR(st->mclk))
> > -		return PTR_ERR(st->mclk);
> > +		return dev_err_probe(&spi->dev, PTR_ERR(st->mclk), "failed to enable MCLK\n");
> >  
> >  	st->spi = spi;
> >  	mutex_init(&st->lock);
> > -- 
> > 2.43.0
> > 
> >