From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: humidity: hts221: add vdd voltage regulator
Date: Sat, 21 Nov 2020 15:44:34 +0000 [thread overview]
Message-ID: <20201121154434.7723d78a@archlinux> (raw)
In-Reply-To: <b2c5ea9dd41cb52eaf484825630bf07ef13510a4.1605777052.git.lorenzo@kernel.org>
On Thu, 19 Nov 2020 10:13:34 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Like all other ST sensors, hts221 devices have VDD power line.
> Introduce VDD voltage regulator to control it.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Hi Lorenzo,
Minor thing about not printing error message is the deferred case.
Otherwise, looks good to me
Thanks,
Jonathan
> ---
> drivers/iio/humidity/hts221.h | 2 ++
> drivers/iio/humidity/hts221_core.c | 39 ++++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/drivers/iio/humidity/hts221.h b/drivers/iio/humidity/hts221.h
> index 721359e226cb..cf3d8d2dccd6 100644
> --- a/drivers/iio/humidity/hts221.h
> +++ b/drivers/iio/humidity/hts221.h
> @@ -13,6 +13,7 @@
> #define HTS221_DEV_NAME "hts221"
>
> #include <linux/iio/iio.h>
> +#include <linux/regulator/consumer.h>
>
> enum hts221_sensor_type {
> HTS221_SENSOR_H,
> @@ -29,6 +30,7 @@ struct hts221_hw {
> const char *name;
> struct device *dev;
> struct regmap *regmap;
> + struct regulator *vdd;
>
> struct iio_trigger *trig;
> int irq;
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index 16657789dc45..e1aa99dcf142 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -547,6 +547,37 @@ static const struct iio_info hts221_info = {
>
> static const unsigned long hts221_scan_masks[] = {0x3, 0x0};
>
> +static int hts221_init_regulators(struct device *dev)
> +{
> + struct iio_dev *iio_dev = dev_get_drvdata(dev);
> + struct hts221_hw *hw = iio_priv(iio_dev);
> + int err;
> +
> + hw->vdd = devm_regulator_get(dev, "vdd");
> + if (IS_ERR(hw->vdd)) {
> + dev_err(dev, "failed to get vdd regulator: %ld\n",
> + PTR_ERR(hw->vdd));
dev_err_probe on this as I would assume we want to not print the message
on deferred response.
> + return PTR_ERR(hw->vdd);
> + }
> +
> + err = regulator_enable(hw->vdd);
> + if (err) {
> + dev_err(dev, "failed to enable vdd regulator: %d\n", err);
> + return err;
> + }
> +
> + msleep(50);
> +
> + return 0;
> +}
> +
> +static void hts221_chip_uninit(void *data)
> +{
> + struct hts221_hw *hw = data;
> +
> + regulator_disable(hw->vdd);
> +}
> +
> int hts221_probe(struct device *dev, int irq, const char *name,
> struct regmap *regmap)
> {
> @@ -567,6 +598,14 @@ int hts221_probe(struct device *dev, int irq, const char *name,
> hw->irq = irq;
> hw->regmap = regmap;
>
> + err = hts221_init_regulators(dev);
> + if (err)
> + return err;
> +
> + err = devm_add_action_or_reset(dev, hts221_chip_uninit, hw);
> + if (err)
> + return err;
> +
> err = hts221_check_whoami(hw);
> if (err < 0)
> return err;
next prev parent reply other threads:[~2020-11-21 15:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 9:13 [PATCH 0/2] hts221: add vdd power regulator Lorenzo Bianconi
2020-11-19 9:13 ` [PATCH 1/2] iio: humidity: hts221: add vdd voltage regulator Lorenzo Bianconi
2020-11-21 15:44 ` Jonathan Cameron [this message]
2020-11-19 9:13 ` [PATCH 2/2] dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings Lorenzo Bianconi
2020-11-21 15:45 ` 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=20201121154434.7723d78a@archlinux \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=lorenzo@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;
as well as URLs for NNTP newsgroup(s).