From: Jonathan Cameron <jic23@kernel.org>
To: Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: dac: ti-dac5571: make vref regulator optional
Date: Sat, 25 Aug 2018 09:55:31 +0100 [thread overview]
Message-ID: <20180825095531.374af32f@archlinux> (raw)
In-Reply-To: <20180824202447.21804-1-marcus.folkesson@gmail.com>
On Fri, 24 Aug 2018 22:24:47 +0200
Marcus Folkesson <marcus.folkesson@gmail.com> wrote:
> The `vref` regulator is declared as optional in the device-tree binding,
> but the driver does require it.
>
> Go for the device-tree binding and make the `vref` regulator optional.
>
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Hmm.
If you do a voltage get on a stub regulator it will return an
error (IIRC).
So I am unconvinced this actually makes any real difference?
What am I missing?
Jonathan
> ---
> drivers/iio/dac/ti-dac5571.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/dac/ti-dac5571.c b/drivers/iio/dac/ti-dac5571.c
> index f6dcd8bce2b0..bf21cc312096 100644
> --- a/drivers/iio/dac/ti-dac5571.c
> +++ b/drivers/iio/dac/ti-dac5571.c
> @@ -251,6 +251,9 @@ static int dac5571_read_raw(struct iio_dev *indio_dev,
> return IIO_VAL_INT;
>
> case IIO_CHAN_INFO_SCALE:
> + if (!data->vref)
> + return -EOPNOTSUPP;
> +
> ret = regulator_get_voltage(data->vref);
> if (ret < 0)
> return ret;
> @@ -335,13 +338,21 @@ static int dac5571_probe(struct i2c_client *client,
> indio_dev->num_channels = spec->num_channels;
> data->spec = spec;
>
> - data->vref = devm_regulator_get(dev, "vref");
> - if (IS_ERR(data->vref))
> - return PTR_ERR(data->vref);
> + data->vref = devm_regulator_get_optional(dev, "vref");
> + if (IS_ERR(data->vref)) {
> + if (PTR_ERR(data->vref) == -ENODEV) {
> + data->vref = NULL;
> + } else {
> + dev_err(dev, "failed to get regulator (%ld)\n",
> + PTR_ERR(data->vref));
> + return PTR_ERR(data->vref);
That is as likely as not a deferred probe so it should not be
as noisy as this. It may happen during a normal boot process a lot
of times.
> + }
>
> - ret = regulator_enable(data->vref);
> - if (ret < 0)
> - return ret;
> + } else {
> + ret = regulator_enable(data->vref);
> + if (ret)
> + return ret;
> + }
>
> mutex_init(&data->lock);
>
> @@ -373,7 +384,9 @@ static int dac5571_probe(struct i2c_client *client,
> return 0;
>
> err:
> - regulator_disable(data->vref);
> + if (data->vref)
> + regulator_disable(data->vref);
> +
> return ret;
> }
>
> @@ -383,7 +396,8 @@ static int dac5571_remove(struct i2c_client *i2c)
> struct dac5571_data *data = iio_priv(indio_dev);
>
> iio_device_unregister(indio_dev);
> - regulator_disable(data->vref);
> + if (data->vref)
> + regulator_disable(data->vref);
>
> return 0;
> }
prev parent reply other threads:[~2018-08-25 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 20:24 [PATCH] iio: dac: ti-dac5571: make vref regulator optional Marcus Folkesson
2018-08-25 8:55 ` 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=20180825095531.374af32f@archlinux \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.folkesson@gmail.com \
--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 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.