From: Jonathan Cameron <jic23@kernel.org>
To: "Paweł Grudziński" <pgrudzinski@openmailbox.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Hartmut Knaack" <knaack.h@gmx.de>,
"Peter Meerwald" <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: dac: ad5380: Fix probe failure when no external reference is supplied
Date: Sun, 24 Jul 2016 11:03:30 +0100 [thread overview]
Message-ID: <d1b6772d-4ad5-d924-76d9-afe6aa644c3f@kernel.org> (raw)
In-Reply-To: <20160719061302.8360-1-pgrudzinski@openmailbox.org>
On 19/07/16 07:12, Paweł Grudziński wrote:
> From: Pawel Grudzinski <pgrudzinski@openmailbox.org>
>
> Driver fails to load when there is no external Vref regulator defined,
> leaving no way to use internal reference. ad5380_probe function tries to
> obtain regulator with demv_regulator_get and checks for error, in which
> case it would use internal reference. Even without "Vref" regulator defined
> devm_regulator_get returns dummy regulator which makes function omit use of
> internal reference and causes failure on regulator_get_voltage.
>
> Replace demv_regulator_get with demv_regulator_get_optional, which returns
> error instead of dummy regulator if it does not find one which is specified
> by the caller to make ad5380_probe configure internal reference when no
> "Vref" regulator is supplied.
>
> Initialize internal regulator only if returned error is ENODEV, otherwise
> propagate the error to the caller of probe.
>
> Signed-off-by: Paweł Grudziński <pgrudzinski@openmailbox.org>
> ---
> Changes in v2:
> - Add error type checking to enable internal reference only on ENODEV and
> return any other error to the caller.
>
> drivers/iio/dac/ad5380.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
> index 97d2c51..144cfdc 100644
> --- a/drivers/iio/dac/ad5380.c
> +++ b/drivers/iio/dac/ad5380.c
> @@ -401,7 +401,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
> if (st->chip_info->int_vref == 2500)
> ctrl |= AD5380_CTRL_INT_VREF_2V5;
>
> - st->vref_reg = devm_regulator_get(dev, "vref");
> + st->vref_reg = devm_regulator_get_optional(dev, "vref");
> if (!IS_ERR(st->vref_reg)) {
> ret = regulator_enable(st->vref_reg);
> if (ret) {
> @@ -416,8 +416,13 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
>
> st->vref = ret / 1000;
> } else {
> - st->vref = st->chip_info->int_vref;
> - ctrl |= AD5380_CTRL_INT_VREF_EN;
> + if (PTR_ERR(st->vref_reg) == -ENODEV) {
> + st->vref = st->chip_info->int_vref;
> + ctrl |= AD5380_CTRL_INT_VREF_EN;
> + } else {
> + ret = st->vref_reg;
Autobuilder picked it up an issue. This should be ret = PTR_ERR(st->vref_reg) I think?
Jonathan
> + goto error_free_reg;
> + }
> }
>
> ret = regmap_write(st->regmap, AD5380_REG_SF_CTRL, ctrl);
>
prev parent reply other threads:[~2016-07-24 10:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 6:12 [PATCH v2] iio: dac: ad5380: Fix probe failure when no external reference is supplied Paweł Grudziński
2016-07-23 15:14 ` kbuild test robot
2016-07-24 10:03 ` Jonathan Cameron [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=d1b6772d-4ad5-d924-76d9-afe6aa644c3f@kernel.org \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pgrudzinski@openmailbox.org \
--cc=pmeerw@pmeerw.net \
/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).