Commit ffebe74b authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jonathan Cameron

iio: humidity: hts221: avoid useless ODR reconfiguration

Configure sensor ODR just in hts221_write_raw() in order to avoid
to set device sample rate multiple times.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent f6f58d9d
...@@ -208,11 +208,6 @@ static int hts221_update_odr(struct hts221_hw *hw, u8 odr) ...@@ -208,11 +208,6 @@ static int hts221_update_odr(struct hts221_hw *hw, u8 odr)
if (err < 0) if (err < 0)
return err; return err;
err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
HTS221_ENABLE_MASK, 1);
if (err < 0)
return err;
hw->odr = odr; hw->odr = odr;
return 0; return 0;
...@@ -294,7 +289,8 @@ int hts221_power_on(struct hts221_hw *hw) ...@@ -294,7 +289,8 @@ int hts221_power_on(struct hts221_hw *hw)
{ {
int err; int err;
err = hts221_update_odr(hw, hw->odr); err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
HTS221_ENABLE_MASK, true);
if (err < 0) if (err < 0)
return err; return err;
...@@ -627,8 +623,6 @@ int hts221_probe(struct iio_dev *iio_dev) ...@@ -627,8 +623,6 @@ int hts221_probe(struct iio_dev *iio_dev)
if (err < 0) if (err < 0)
return err; return err;
hw->odr = hts221_odr_table[0].hz;
iio_dev->modes = INDIO_DIRECT_MODE; iio_dev->modes = INDIO_DIRECT_MODE;
iio_dev->dev.parent = hw->dev; iio_dev->dev.parent = hw->dev;
iio_dev->available_scan_masks = hts221_scan_masks; iio_dev->available_scan_masks = hts221_scan_masks;
...@@ -643,6 +637,10 @@ int hts221_probe(struct iio_dev *iio_dev) ...@@ -643,6 +637,10 @@ int hts221_probe(struct iio_dev *iio_dev)
if (err < 0) if (err < 0)
return err; return err;
err = hts221_update_odr(hw, hts221_odr_table[0].hz);
if (err < 0)
return err;
/* configure humidity sensor */ /* configure humidity sensor */
err = hts221_parse_rh_caldata(hw); err = hts221_parse_rh_caldata(hw);
if (err < 0) { if (err < 0) {
...@@ -706,7 +704,8 @@ static int __maybe_unused hts221_resume(struct device *dev) ...@@ -706,7 +704,8 @@ static int __maybe_unused hts221_resume(struct device *dev)
int err = 0; int err = 0;
if (hw->enabled) if (hw->enabled)
err = hts221_update_odr(hw, hw->odr); err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
HTS221_ENABLE_MASK, true);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment