Skip to content

Commit f3f0ae1

Browse files
LorenzoBianconiJonathan Cameron
authored andcommitted
iio: humidity: hts221: move drdy enable logic in hts221_trig_set_state()
Move data-ready configuration in hts221_buffer.c since it is only related to trigger logic Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 21d841b commit f3f0ae1

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

‎drivers/iio/humidity/hts221.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct hts221_hw {
6060

6161
extern const struct dev_pm_ops hts221_pm_ops;
6262

63-
int hts221_config_drdy(struct hts221_hw *hw, bool enable);
6463
int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask, u8 val);
6564
int hts221_probe(struct iio_dev *iio_dev);
6665
int hts221_set_enable(struct hts221_hw *hw, bool enable);

‎drivers/iio/humidity/hts221_buffer.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#define HTS221_REG_DRDY_HL_MASK BIT(7)
2929
#define HTS221_REG_DRDY_PP_OD_ADDR 0x22
3030
#define HTS221_REG_DRDY_PP_OD_MASK BIT(6)
31+
#define HTS221_REG_DRDY_EN_ADDR 0x22
32+
#define HTS221_REG_DRDY_EN_MASK BIT(2)
3133
#define HTS221_REG_STATUS_ADDR 0x27
3234
#define HTS221_RH_DRDY_MASK BIT(1)
3335
#define HTS221_TEMP_DRDY_MASK BIT(0)
@@ -36,8 +38,12 @@ static int hts221_trig_set_state(struct iio_trigger *trig, bool state)
3638
{
3739
struct iio_dev *iio_dev = iio_trigger_get_drvdata(trig);
3840
struct hts221_hw *hw = iio_priv(iio_dev);
41+
int err;
42+
43+
err = hts221_write_with_mask(hw, HTS221_REG_DRDY_EN_ADDR,
44+
HTS221_REG_DRDY_EN_MASK, state);
3945

40-
return hts221_config_drdy(hw, state);
46+
return err < 0 ? err : 0;
4147
}
4248

4349
static const struct iio_trigger_ops hts221_trigger_ops = {

‎drivers/iio/humidity/hts221_core.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#define HTS221_REG_CNTRL1_ADDR 0x20
2525
#define HTS221_REG_CNTRL2_ADDR 0x21
26-
#define HTS221_REG_CNTRL3_ADDR 0x22
2726

2827
#define HTS221_REG_AVG_ADDR 0x10
2928
#define HTS221_REG_H_OUT_L 0x28
@@ -36,9 +35,6 @@
3635
#define HTS221_BDU_MASK BIT(2)
3736
#define HTS221_ENABLE_MASK BIT(7)
3837

39-
#define HTS221_DRDY_MASK BIT(2)
40-
41-
4238
/* calibration registers */
4339
#define HTS221_REG_0RH_CAL_X_H 0x36
4440
#define HTS221_REG_1RH_CAL_X_H 0x3a
@@ -181,16 +177,6 @@ static int hts221_check_whoami(struct hts221_hw *hw)
181177
return 0;
182178
}
183179

184-
int hts221_config_drdy(struct hts221_hw *hw, bool enable)
185-
{
186-
int err;
187-
188-
err = hts221_write_with_mask(hw, HTS221_REG_CNTRL3_ADDR,
189-
HTS221_DRDY_MASK, enable);
190-
191-
return err < 0 ? err : 0;
192-
}
193-
194180
static int hts221_update_odr(struct hts221_hw *hw, u8 odr)
195181
{
196182
int i, err;

0 commit comments

Comments
 (0)