linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][for iio-for-4.17b] iio: humidity: hts221: Fix sensor reads after resume
@ 2018-04-30  5:16 Shrirang Bagul
  2018-04-30  7:48 ` Lorenzo Bianconi
  0 siblings, 1 reply; 9+ messages in thread
From: Shrirang Bagul @ 2018-04-30  5:16 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi83, linux-iio

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-for-4.17b

Fixes: ffebe74b7c95 (iio: humidity: hts221: avoid useless ODR reconfiguration)
Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
---
 drivers/iio/humidity/hts221_core.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 166946d4978d..5d7a652aa6d9 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -658,12 +658,13 @@ static int __maybe_unused hts221_resume(struct device *dev)
 	struct hts221_hw *hw = iio_priv(iio_dev);
 	int err = 0;
 
-	if (hw->enabled)
-		err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR,
-					 HTS221_ENABLE_MASK,
-					 FIELD_PREP(HTS221_ENABLE_MASK,
-						    true));
-	return err;
+	err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR,
+				 HTS221_BDU_MASK,
+				 FIELD_PREP(HTS221_BDU_MASK, 1));
+	if (err < 0)
+		return err;
+
+	return hts221_update_odr(hw, hw->odr);
 }
 
 const struct dev_pm_ops hts221_pm_ops = {
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-03 10:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-30  5:16 [PATCH][for iio-for-4.17b] iio: humidity: hts221: Fix sensor reads after resume Shrirang Bagul
2018-04-30  7:48 ` Lorenzo Bianconi
2018-04-30  8:39   ` Shrirang Bagul
2018-04-30  8:49   ` Shrirang Bagul
2018-04-30  9:05     ` Lorenzo Bianconi
2018-04-30  9:12       ` Shrirang Bagul
2018-05-03  7:39         ` Shrirang Bagul
2018-05-03  9:30           ` Lorenzo Bianconi
2018-05-03 10:49             ` 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).