From: Jonathan Cameron <jic23@kernel.org>
To: Shrirang Bagul <shrirang.bagul@canonical.com>
Cc: lorenzo.bianconi83@gmail.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: humidity: hts221: Fix sensor reads after resume
Date: Sun, 6 May 2018 17:19:42 +0100 [thread overview]
Message-ID: <20180506171942.0a4802d7@archlinux> (raw)
In-Reply-To: <20180430042546.8801-1-shrirang.bagul@canonical.com>
On Mon, 30 Apr 2018 12:25:46 +0800
Shrirang Bagul <shrirang.bagul@canonical.com> wrote:
> CTRL1 register (ODR & BDU settings) gets reset after system comes back
> from suspend, causing subsequent reads from the sensor to fail.
>
> This patch restores the CTRL1 register after resume.
>
> Based on:
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git iio-fixes-for-4.14b
>
> Since 4.17.rc1, this driver uses REGMAP; I'll send a separate patch to
> address this issue.
>
> Cc: stable@vger.kernel.org
> Fixes: ffebe74b7c95 (iio: humidity: hts221: avoid useless ODR reconfiguration)
Looks like part of the problem was introduced in that patch, part well predated
it (BDU).
> Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
As you way, this needs to be a bit different to take into account
the change to regmap. We'll need to have that upstream before we look
at a back port. One element inline surprises me and needs further
explanation.
> ---
> drivers/iio/humidity/hts221_core.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index 32524a8dc66f..fed2da64fa3b 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -674,11 +674,15 @@ static int __maybe_unused hts221_resume(struct device *dev)
> struct hts221_hw *hw = iio_priv(iio_dev);
> int err = 0;
>
> - if (hw->enabled)
> - err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
> - HTS221_ENABLE_MASK, true);
Why drop the enable setting? Seems that we want to do this 'as well',
if the device was previous enabled.
> + err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
> + HTS221_BDU_MASK, 1);
> + if (err < 0)
> + goto fail_err;
>
> - return err;
> + err = hts221_update_odr(hw, hw->odr);
> +
> +fail_err:
> + return err < 0 ? err : 0;
> }
>
> const struct dev_pm_ops hts221_pm_ops = {
next prev parent reply other threads:[~2018-05-06 16:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-30 4:25 [PATCH] iio: humidity: hts221: Fix sensor reads after resume Shrirang Bagul
2018-05-06 16:19 ` Jonathan Cameron [this message]
2018-05-07 2:21 ` Shrirang Bagul
2018-05-07 21:34 ` Lorenzo Bianconi
2018-05-08 2:55 ` Shrirang Bagul
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=20180506171942.0a4802d7@archlinux \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=shrirang.bagul@canonical.com \
/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.