All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Tachici <alexandru.tachici@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/5 V2] staging: iio: adc: ad7192: fail probe on get_voltage
Date: Thu, 6 Feb 2020 09:56:59 +0000	[thread overview]
Message-ID: <20200206095659.639218f7@archlinux> (raw)
In-Reply-To: <20200205171511.25912-2-alexandru.tachici@analog.com>

On Wed, 5 Feb 2020 19:15:07 +0200
Alexandru Tachici <alexandru.tachici@analog.com> wrote:

> This patch makes the ad7192_probe fail in case
> regulator_get_voltage will return an error.
> 
> Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>

There is a subtlety in here we should handle.

> ---
>  drivers/staging/iio/adc/ad7192.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
> index bf3e2a9cc07f..4780ddf99b13 100644
> --- a/drivers/staging/iio/adc/ad7192.c
> +++ b/drivers/staging/iio/adc/ad7192.c
> @@ -899,10 +899,13 @@ static int ad7192_probe(struct spi_device *spi)
>  
>  	voltage_uv = regulator_get_voltage(st->avdd);
>
I had to dig a bit to check this as it's not documented.
regulator_get_voltage returns negative for error, not 0.
0 typically means the voltage has not been set or has been
explicitly set to 0. 

So if it is set to 0 I suppose we could try setting it as it
might be a variable high precision reference?

Perhaps for now just spitting out an error is the best plan.

  
> -	if (voltage_uv)
> +	if (voltage_uv) {
>  		st->int_vref_mv = voltage_uv / 1000;
> -	else
> +	} else {
> +		ret = voltage_uv;
>  		dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
> +		goto error_disable_avdd;
> +	}
>  
>  	spi_set_drvdata(spi, indio_dev);
>  	st->devid = spi_get_device_id(spi)->driver_data;
> @@ -957,6 +960,7 @@ static int ad7192_probe(struct spi_device *spi)
>  	ret = iio_device_register(indio_dev);
>  	if (ret < 0)
>  		goto error_disable_clk;
> +
We shouldn't have stray white space changes in a patch making a real change.

Thanks,

Jonathan

>  	return 0;
>  
>  error_disable_clk:


  reply	other threads:[~2020-02-06  9:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22  8:54 [PATCH] iio: adc: ad7124: add 3db filter Alexandru Tachici
2020-02-02 16:22 ` Jonathan Cameron
2020-02-05 17:12   ` [PATCH 0/5 V2] iio: adc: ad7192: move out of staging Alexandru Tachici
2020-02-05 17:15   ` Alexandru Tachici
2020-02-05 17:15     ` [PATCH 1/5 V2] staging: iio: adc: ad7192: fail probe on get_voltage Alexandru Tachici
2020-02-06  9:56       ` Jonathan Cameron [this message]
2020-02-05 17:15     ` [PATCH 2/5 V2] staging: iio: adc: ad7192: modify iio_chan_spec array Alexandru Tachici
2020-02-06 10:01       ` Jonathan Cameron
2020-02-05 17:15     ` [PATCH 3/5 V2] staging: iio: adc: ad7192: removed spi_device_id Alexandru Tachici
2020-02-06 10:03       ` Jonathan Cameron
2020-02-05 17:15     ` [PATCH 4/5 V2] Documentation: ABI: testing: ad7192: update sysfs docs Alexandru Tachici
2020-02-06 10:05       ` Jonathan Cameron
2020-02-05 17:15     ` [PATCH 5/5 V2] staging: iio: adc: ad7192: move out of staging Alexandru Tachici
2020-02-06 10:10       ` Jonathan Cameron
2020-02-06 10:20         ` Jonathan Cameron
2020-02-10  6:43           ` Ardelean, Alexandru
2020-02-14 13:03             ` Jonathan Cameron
2020-02-06  9:47     ` [PATCH 0/5 V2] " Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200206095659.639218f7@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandru.tachici@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.