From: Jonathan Cameron <jic23@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Subject: Re: [PATCH 2/4] iio: accel: bma180: Basic regulator support
Date: Mon, 23 Dec 2019 17:20:40 +0000 [thread overview]
Message-ID: <20191223172040.176524aa@archlinux> (raw)
In-Reply-To: <20191211213819.14024-2-linus.walleij@linaro.org>
On Wed, 11 Dec 2019 22:38:17 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:
> This brings up the VDD and VDDIO regulators using the
> regulator framework. Platforms that do not use regulators
> will provide stubs or dummy regulators.
>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>
> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
I made a totally trivial tweak. See below.
Applied to the togreg branch of iio.git and pushed out as testing..
etc. etc.
Jonathan
> ---
> drivers/iio/accel/bma180.c | 43 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index 518efbe4eaf6..4a619b5a544a 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -18,6 +18,7 @@
> #include <linux/of_device.h>
> #include <linux/of.h>
> #include <linux/bitops.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/slab.h>
> #include <linux/string.h>
> #include <linux/iio/iio.h>
> @@ -110,6 +111,8 @@ struct bma180_part_info {
> #define BMA250_INT_RESET_MASK BIT(7) /* Reset pending interrupts */
>
> struct bma180_data {
> + struct regulator *vdd_supply;
> + struct regulator *vddio_supply;
> struct i2c_client *client;
> struct iio_trigger *trig;
> const struct bma180_part_info *part_info;
> @@ -736,6 +739,40 @@ static int bma180_probe(struct i2c_client *client,
> if (ret)
> return ret;
>
> + data->vdd_supply = devm_regulator_get(dev, "vdd");
> + if (IS_ERR(data->vdd_supply)) {
> + if (PTR_ERR(data->vdd_supply) != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get vdd regulator %d\n",
> + (int)PTR_ERR(data->vdd_supply));
> + return PTR_ERR(data->vdd_supply);
> + }
> + data->vddio_supply = devm_regulator_get(dev, "vddio");
> + if (IS_ERR(data->vddio_supply)) {
> + if (PTR_ERR(data->vddio_supply) != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get vddio regulator %d\n",
> + (int)PTR_ERR(data->vddio_supply));
> + return PTR_ERR(data->vddio_supply);
> + }
> + /* Typical voltage 2.4V these are min and max */
> + ret = regulator_set_voltage(data->vdd_supply, 1620000, 3600000);
> + if (ret)
> + return ret;
> + ret = regulator_set_voltage(data->vddio_supply, 1200000, 3600000);
> + if (ret)
> + return ret;
> + ret = regulator_enable(data->vdd_supply);
> + if (ret) {
> + dev_err(dev, "Failed to enable vdd regulator: %d\n", ret);
> + return ret;
> + }
> + ret = regulator_enable(data->vddio_supply);
> + if (ret) {
> + dev_err(dev, "Failed to enable vddio regulator: %d\n", ret);
> + goto err_disable_vdd;
> + }
> + /* Wait to make sure we started up properly (3 ms at least) */
> + usleep_range(3000, 5000);
> +
> ret = data->part_info->chip_config(data);
> if (ret < 0)
> goto err_chip_disable;
> @@ -798,7 +835,9 @@ static int bma180_probe(struct i2c_client *client,
> iio_trigger_free(data->trig);
> err_chip_disable:
> data->part_info->chip_disable(data);
> -
If I were feeling really nit pick friendly. Don't mess with the whitespace!
> + regulator_disable(data->vddio_supply);
> +err_disable_vdd:
> + regulator_disable(data->vdd_supply);
> return ret;
> }
>
> @@ -817,6 +856,8 @@ static int bma180_remove(struct i2c_client *client)
> mutex_lock(&data->mutex);
> data->part_info->chip_disable(data);
> mutex_unlock(&data->mutex);
> + regulator_disable(data->vddio_supply);
> + regulator_disable(data->vdd_supply);
>
> return 0;
> }
next prev parent reply other threads:[~2019-12-23 17:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 21:38 [PATCH 1/4] iio: accel: bma180: Add dev helper variable Linus Walleij
2019-12-11 21:38 ` [PATCH 2/4] iio: accel: bma180: Basic regulator support Linus Walleij
2019-12-23 17:20 ` Jonathan Cameron [this message]
2019-12-11 21:38 ` [PATCH 3/4] iio: accel: bma180: Use explicit member assignment Linus Walleij
2019-12-23 17:22 ` Jonathan Cameron
2019-12-11 21:38 ` [PATCH 4/4] iio: accel: bma180: BMA254 support Linus Walleij
2019-12-19 21:49 ` Rob Herring
2019-12-23 17:28 ` Jonathan Cameron
2019-12-23 20:18 ` Linus Walleij
2019-12-23 17:18 ` [PATCH 1/4] iio: accel: bma180: Add dev helper variable 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=20191223172040.176524aa@archlinux \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=o.v.kravchenko@globallogic.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.