From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, <Michael.Hennerich@analog.com>,
<Dragos.Bogdan@analog.com>, <knaack.h@gmx.de>,
<pmeerw@pmeerw.net>
Subject: Re: [PATCH 2/4] staging: iio: ad5933: Add regulator binding for vref
Date: Sun, 7 Oct 2018 20:30:31 +0100 [thread overview]
Message-ID: <20181007203031.6545485a@archlinux> (raw)
In-Reply-To: <20181002115800.12399-2-alexandru.ardelean@analog.com>
On Tue, 2 Oct 2018 14:57:58 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> From: Dragos Bogdan <dragos.bogdan@analog.com>
>
> In order to add full device tree support, add the option of specifying
> the vref using the regulator framework.
>
> Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
> drivers/staging/iio/impedance-analyzer/ad5933.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 8a920f675b83..ec54ab4471b9 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -97,6 +97,7 @@ struct ad5933_platform_data {
> struct ad5933_state {
> struct i2c_client *client;
> struct regulator *reg;
> + struct regulator *vref;
> struct delayed_work work;
> struct mutex lock; /* Protect sensor state */
> unsigned long mclk_hz;
> @@ -721,6 +722,14 @@ static int ad5933_probe(struct i2c_client *client,
> }
> voltage_uv = regulator_get_voltage(st->reg);
>
> + st->reg = devm_regulator_get(&client->dev, "vref");
You want devm_regulator_get_optional here I think.
Otherwise you'll get a stub regulator if one isn't specified in
the device tree.
Also, I'm confused, you have an existing regulator which you
override with a second one? Please provide some more details of
this..
> + if (!IS_ERR(st->vref)) {
> + ret = regulator_enable(st->vref);
> + if (ret)
> + goto error_disable_reg;
> + pdata->vref_mv = regulator_get_voltage(st->vref) / 1000;
> + }
> +
> if (voltage_uv)
> st->vref_mv = voltage_uv / 1000;
> else
> @@ -747,7 +756,7 @@ static int ad5933_probe(struct i2c_client *client,
>
> ret = ad5933_register_ring_funcs_and_init(indio_dev);
> if (ret)
> - goto error_disable_reg;
> + goto error_disable_vref;
>
> ret = ad5933_setup(st);
> if (ret)
> @@ -761,6 +770,8 @@ static int ad5933_probe(struct i2c_client *client,
>
> error_unreg_ring:
> iio_kfifo_free(indio_dev->buffer);
> +error_disable_vref:
> + regulator_disable(st->vref);
> error_disable_reg:
> regulator_disable(st->reg);
>
> @@ -775,6 +786,7 @@ static int ad5933_remove(struct i2c_client *client)
> iio_device_unregister(indio_dev);
> iio_kfifo_free(indio_dev->buffer);
> regulator_disable(st->reg);
> + regulator_disable(st->vref);
>
> return 0;
> }
next prev parent reply other threads:[~2018-10-08 2:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-02 11:57 [PATCH 1/4] staging: iio: ad5933: rename ext_clk_Hz -> ext_clk_hz Alexandru Ardelean
2018-10-02 11:57 ` [PATCH 2/4] staging: iio: ad5933: Add regulator binding for vref Alexandru Ardelean
2018-10-07 19:30 ` Jonathan Cameron [this message]
2018-10-02 11:57 ` [PATCH 3/4] staging: iio: ad5933: Use the clock framework for the external clock Alexandru Ardelean
2018-10-07 19:32 ` Jonathan Cameron
2018-10-02 11:58 ` [PATCH 4/4] staging: iio: ad5933: Add of_device_id table Alexandru Ardelean
2018-10-07 19:34 ` Jonathan Cameron
2018-10-07 15:54 ` [PATCH 1/4] staging: iio: ad5933: rename ext_clk_Hz -> ext_clk_hz 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=20181007203031.6545485a@archlinux \
--to=jic23@kernel.org \
--cc=Dragos.Bogdan@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.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).