linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Boor <florian.boor@kernelconcepts.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, Jonathan.Cameron@huawei.com,
	Michael.Hennerich@analog.com
Subject: Re: [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999.
Date: Tue, 14 Sep 2021 15:21:32 +0200	[thread overview]
Message-ID: <bda7156d-bf75-65c2-e2b5-b42eca5e0915@kernelconcepts.de> (raw)
In-Reply-To: <20210911174306.16779384@jic23-huawei>

Hi Jonathan,

On 11.09.21 18:43, Jonathan Cameron wrote:
> On Wed,  8 Sep 2021 17:25:24 +0200
> Florian Boor <florian.boor@kernelconcepts.de> wrote:
> 
>> Make use of the AD7991_REF_SEL bit and support using the external
>> reference voltage if 'vref-supply' is present.
>>
>> Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
> 
> Hi Florian,
> 
>> ---
>>
>> Changes in v2:
>> - Check if a provided external vref regulator is provided.
>> - Drop unused setting
>> - Add ad79xx documentation (second patch)
>>
>>  drivers/iio/adc/ad799x.c | 21 +++++++++++++++++++--
>>  1 file changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
>> index 18bf8386d50a..2ff926a4e9b3 100644
>> --- a/drivers/iio/adc/ad799x.c
>> +++ b/drivers/iio/adc/ad799x.c
>> @@ -770,6 +770,8 @@ static int ad799x_probe(struct i2c_client *client,
>>  				   const struct i2c_device_id *id)
>>  {
>>  	int ret;
>> +	int extra_config = 0;
>> +	bool vref_external = true;
>>  	struct ad799x_state *st;
>>  	struct iio_dev *indio_dev;
>>  	const struct ad799x_chip_info *chip_info =
>> @@ -797,7 +799,15 @@ static int ad799x_probe(struct i2c_client *client,
>>  	ret = regulator_enable(st->reg);
>>  	if (ret)
>>  		return ret;
>> -	st->vref = devm_regulator_get(&client->dev, "vref");
>> +		
>> +	/* check if an external reference is supplied */
>> +	st->vref = devm_regulator_get_optional(&client->dev, "vref");
>> +
>> +	if (PTR_ERR(st->vref) == -ENODEV) {
>> +		vref_external = false;
>> +		/* get dummy */
>> +		st->vref = devm_regulator_get(&client->dev, "vref");
> 
> Why?  Instead of doing this add if (st->vref) around the regulator
> enable and disable.  We don't want to pretend there is a regulator when
> there isn't one connected and we are using VDD as the reference.
> 
> If we are in that mode, we need to change which regulator is read in
> read_raw()

I have to admit I wondered about how this is handled as well. My idea was not to
change it at this point and improve this later in a separate patch.
But I see the point - I'll add this change as well.

Greetings

Florian

-- 
The dream of yesterday                  Florian Boor
is the hope of today                    Tel: +49(0) 271-338857-15
and the reality of tomorrow.		Fax: +49(0) 271-338857-29
[Robert Hutchings Goddard, 1904]        florian.boor@kernelconcepts.de
                                        http://www.kernelconcepts.de/en

kernel concepts GmbH
Hauptstraße 16
57074 Siegen
Deutschland
Geschäftsführer: Ole Reinhardt
HR Siegen, HR B 9613

      reply	other threads:[~2021-09-14 13:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 15:25 [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Florian Boor
2021-09-08 15:25 ` [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver Florian Boor
2021-09-11 16:34   ` Jonathan Cameron
2021-09-11 16:43 ` [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Jonathan Cameron
2021-09-14 13:21   ` Florian Boor [this message]

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=bda7156d-bf75-65c2-e2b5-b42eca5e0915@kernelconcepts.de \
    --to=florian.boor@kernelconcepts.de \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).