iio: humidity: hts221: move BDU configuration in probe routine
authorLorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Mon, 17 Jul 2017 17:38:57 +0000 (19:38 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 22 Jul 2017 20:18:08 +0000 (21:18 +0100)
Enable Block Data Update in hts221_probe() in order to avoid to reconfigure
it every time the sensor is enabled

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 d2f5962..47a29b2 100644 (file)
@@ -203,12 +203,6 @@ static int hts221_update_odr(struct hts221_hw *hw, u8 odr)
        if (i == ARRAY_SIZE(hts221_odr_table))
                return -EINVAL;
 
-       /* enable Block Data Update */
-       err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
-                                    HTS221_BDU_MASK, 1);
-       if (err < 0)
-               return err;
-
        err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
                                     HTS221_ODR_MASK, hts221_odr_table[i].val);
        if (err < 0)
@@ -644,6 +638,12 @@ int hts221_probe(struct iio_dev *iio_dev)
        iio_dev->name = HTS221_DEV_NAME;
        iio_dev->info = &hts221_info;
 
+       /* enable Block Data Update */
+       err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
+                                    HTS221_BDU_MASK, 1);
+       if (err < 0)
+               return err;
+
        /* configure humidity sensor */
        err = hts221_parse_rh_caldata(hw);
        if (err < 0) {