public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Michael Hennerich <michael.hennerich@analog.com>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v3 1/2] iio:adc:ad7476: Handle the different regulators used by various parts.
Date: Sun, 25 Apr 2021 17:02:53 +0100	[thread overview]
Message-ID: <20210425170253.577b0f41@jic23-huawei> (raw)
In-Reply-To: <20210425161802.2627e4b8@jic23-huawei>

On Sun, 25 Apr 2021 16:18:02 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Sat, 24 Apr 2021 20:20:41 +0200
> Lars-Peter Clausen <lars@metafoo.de> wrote:
> 
> > On 4/24/21 7:03 PM, Jonathan Cameron wrote:  
> > > [...]
> > >   
> > > +	/* Either vcc or vref (below) as appropriate */
> > > +	if (!st->chip_info->int_vref_uv)
> > > +		st->ref_reg = reg;
> > > +
> > > +	if (st->chip_info->has_vref) {
> > > +
> > > +		/* If a device has an internal reference vref is optional */
> > > +		if (st->chip_info->int_vref_uv) {
> > > +			reg = devm_regulator_get_optional(&spi->dev, "vref");
> > > +		} else {
> > > +			reg = devm_regulator_get(&spi->dev, "vref");
> > > +			if (IS_ERR(reg))
> > > +				return PTR_ERR(reg);
> > > +		}
> > > +
> > > +		if (!IS_ERR(reg)) {
> > > +			ret = regulator_enable(reg);
> > > +			if (ret)
> > > +				return ret;
> > > +
> > > +			ret = devm_add_action_or_reset(&spi->dev,
> > > +						       ad7476_reg_disable,
> > > +						       reg);
> > > +			if (ret)
> > > +				return ret;
> > > +			st->ref_reg = reg;
> > > +		} else {    
> > We still need to check for errors, e.g. to support EPROBE_DEFER. The 
> > only error that can be ignored is ENOENT, which means no regulator is 
> > specified.  
> Good point.  I got fixated on all the different combinations and forgot the
> simple 'error' case :)

As far as I can tell -ENODEV is the return for no regulator specified.

Jonathan

> 
> V4 coming up.
> 
> Jonathan
> 
> > > +			/*
> > > +			 * Can only get here if device supports both internal
> > > +			 * and external reference, but the regulator connected
> > > +			 * to the external reference is not connected.
> > > +			 * Set the reference regulator pointer to NULL to
> > > +			 * indicate this.
> > > +			 */
> > > +			st->ref_reg = NULL;
> > > +		}
> > > +	}    
> >   
> 


  reply	other threads:[~2021-04-25 16:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24 17:03 [PATCH v3 0/2] iio:adc:ad7476: Regulator support and binding doc Jonathan Cameron
2021-04-24 17:03 ` [PATCH v3 1/2] iio:adc:ad7476: Handle the different regulators used by various parts Jonathan Cameron
2021-04-24 18:20   ` Lars-Peter Clausen
2021-04-25 15:18     ` Jonathan Cameron
2021-04-25 16:02       ` Jonathan Cameron [this message]
2021-04-25 16:07         ` Lars-Peter Clausen
2021-04-24 17:03 ` [PATCH v3 2/2] dt-bindings:iio:adc:adi,ad7474: Add missing binding document Jonathan Cameron
2021-04-24 17:09   ` 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=20210425170253.577b0f41@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=michael.hennerich@analog.com \
    --cc=robh+dt@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