LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] iio: humidity: hts221: Fix sensor reads after resume
@ 2018-04-30 4:25 Shrirang Bagul
2018-05-06 16:19 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Shrirang Bagul @ 2018-04-30 4:25 UTC (permalink / raw)
To: jic23; +Cc: lorenzo.bianconi83, linux-iio, linux-kernel
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)
Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
---
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);
+ 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 = {
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: humidity: hts221: Fix sensor reads after resume
2018-04-30 4:25 [PATCH] iio: humidity: hts221: Fix sensor reads after resume Shrirang Bagul
@ 2018-05-06 16:19 ` Jonathan Cameron
2018-05-07 2:21 ` Shrirang Bagul
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2018-05-06 16:19 UTC (permalink / raw)
To: Shrirang Bagul; +Cc: lorenzo.bianconi83, linux-iio, linux-kernel
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 = {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: humidity: hts221: Fix sensor reads after resume
2018-05-06 16:19 ` Jonathan Cameron
@ 2018-05-07 2:21 ` Shrirang Bagul
0 siblings, 0 replies; 3+ messages in thread
From: Shrirang Bagul @ 2018-05-07 2:21 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: lorenzo.bianconi83, linux-iio, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2523 bytes --]
On Sun, 2018-05-06 at 17:19 +0100, Jonathan Cameron wrote:
> 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.
I have sent a patch based on iio-for-4.17b [1], Lorenzo and I are still
discussing our findings. It's not just the CTRL1 reg, but also the AV_CONF(0x10) reg.
which loses it's contents coming out of suspend.
[1] https://marc.info/?l=linux-iio&m=152534455701742&w=2
>
>
> > ---
> > 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.
Yes, will cover this in v2.
>
> > + 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 = {
>
>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-07 2:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 4:25 [PATCH] iio: humidity: hts221: Fix sensor reads after resume Shrirang Bagul
2018-05-06 16:19 ` Jonathan Cameron
2018-05-07 2:21 ` Shrirang Bagul
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).