iio: humidity: hts221: squash hts221_power_on/off in hts221_set_enable
authorLorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Mon, 17 Jul 2017 17:39:00 +0000 (19:39 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 22 Jul 2017 20:20:48 +0000 (21:20 +0100)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/humidity/hts221.h
drivers/iio/humidity/hts221_buffer.c
drivers/iio/humidity/hts221_core.c

index bf33d8f6396cf151bd423c4395c73e9ae717a9ba..69dfa5c63ec299fe373fdd883425da8b9e077f07 100644 (file)
@@ -62,8 +62,7 @@ extern const struct dev_pm_ops hts221_pm_ops;
 
 int hts221_config_drdy(struct hts221_hw *hw, bool enable);
 int hts221_probe(struct iio_dev *iio_dev);
-int hts221_power_on(struct hts221_hw *hw);
-int hts221_power_off(struct hts221_hw *hw);
+int hts221_set_enable(struct hts221_hw *hw, bool enable);
 int hts221_allocate_buffers(struct hts221_hw *hw);
 int hts221_allocate_trigger(struct hts221_hw *hw);
 
index 7d19a3da7ab740394463a0ed2c3128ea57ea5dff..c4ed153ad3974f9c292f8d91d3a329a186df0d70 100644 (file)
@@ -109,12 +109,12 @@ int hts221_allocate_trigger(struct hts221_hw *hw)
 
 static int hts221_buffer_preenable(struct iio_dev *iio_dev)
 {
-       return hts221_power_on(iio_priv(iio_dev));
+       return hts221_set_enable(iio_priv(iio_dev), true);
 }
 
 static int hts221_buffer_postdisable(struct iio_dev *iio_dev)
 {
-       return hts221_power_off(iio_priv(iio_dev));
+       return hts221_set_enable(iio_priv(iio_dev), false);
 }
 
 static const struct iio_buffer_setup_ops hts221_buffer_ops = {
index f99adc44139ed6c130eb7a949b7ea178be9c5cce..dc55d9fbc702a9806838204ce1b54cbd228bd70c 100644 (file)
@@ -285,30 +285,16 @@ hts221_sysfs_temp_oversampling_avail(struct device *dev,
        return len;
 }
 
-int hts221_power_on(struct hts221_hw *hw)
+int hts221_set_enable(struct hts221_hw *hw, bool enable)
 {
        int err;
 
        err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
-                                    HTS221_ENABLE_MASK, true);
+                                    HTS221_ENABLE_MASK, enable);
        if (err < 0)
                return err;
 
-       hw->enabled = true;
-
-       return 0;
-}
-
-int hts221_power_off(struct hts221_hw *hw)
-{
-       int err;
-
-       err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
-                                    HTS221_ENABLE_MASK, false);
-       if (err < 0)
-               return err;
-
-       hw->enabled = false;
+       hw->enabled = enable;
 
        return 0;
 }
@@ -463,7 +449,7 @@ static int hts221_read_oneshot(struct hts221_hw *hw, u8 addr, int *val)
        u8 data[HTS221_DATA_SIZE];
        int err;
 
-       err = hts221_power_on(hw);
+       err = hts221_set_enable(hw, true);
        if (err < 0)
                return err;
 
@@ -473,7 +459,7 @@ static int hts221_read_oneshot(struct hts221_hw *hw, u8 addr, int *val)
        if (err < 0)
                return err;
 
-       hts221_power_off(hw);
+       hts221_set_enable(hw, false);
 
        *val = (s16)get_unaligned_le16(data);