iio: humidity: hts221: do not overwrite reserved data during power-down
authorLorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Mon, 17 Jul 2017 17:38:58 +0000 (19:38 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 22 Jul 2017 20:18:11 +0000 (21:18 +0100)
GENMASK(6, 3) in CTRL_REG1 and GENMASK(6, 2) in CTRL_REG2 are marked
reserved. Do not changed the original value (not declared in the
datasheet) during power-down/suspend routines.

Fixes: e4a70e3e7d84 (iio: humidity: add support to hts221 rh/temp device)
Fixes: b7079eeac5da (iio: humidity: hts221: add power management support)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/humidity/hts221_core.c

index 47a29b2da1ce1d1438f5390860cdbc0890b264bf..6e5847386a45955b44c8caa9329842a4f1fd70dd 100644 (file)
@@ -305,11 +305,10 @@ int hts221_power_on(struct hts221_hw *hw)
 
 int hts221_power_off(struct hts221_hw *hw)
 {
-       __le16 data = 0;
        int err;
 
-       err = hw->tf->write(hw->dev, HTS221_REG_CNTRL1_ADDR, sizeof(data),
-                           (u8 *)&data);
+       err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
+                                    HTS221_ENABLE_MASK, false);
        if (err < 0)
                return err;
 
@@ -692,11 +691,10 @@ static int __maybe_unused hts221_suspend(struct device *dev)
 {
        struct iio_dev *iio_dev = dev_get_drvdata(dev);
        struct hts221_hw *hw = iio_priv(iio_dev);
-       __le16 data = 0;
        int err;
 
-       err = hw->tf->write(hw->dev, HTS221_REG_CNTRL1_ADDR, sizeof(data),
-                           (u8 *)&data);
+       err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
+                                    HTS221_ENABLE_MASK, false);
 
        return err < 0 ? err : 0;
 }