diff options
author | Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> | 2017-07-17 13:38:59 -0400 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2017-07-22 16:18:37 -0400 |
commit | ffebe74b7c95a41d2d0ac70a44d410e0efa37ad8 (patch) | |
tree | 8c6206dec288d84edd5588caa1feb03426115ab0 /drivers/iio/humidity | |
parent | f6f58d9d93fdb53f24b0086ce1c51d3388aa6e53 (diff) |
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: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/humidity')
-rw-r--r-- | drivers/iio/humidity/hts221_core.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index 6e5847386a45..f99adc44139e 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c | |||
@@ -208,11 +208,6 @@ static int hts221_update_odr(struct hts221_hw *hw, u8 odr) | |||
208 | if (err < 0) | 208 | if (err < 0) |
209 | return err; | 209 | return err; |
210 | 210 | ||
211 | err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR, | ||
212 | HTS221_ENABLE_MASK, 1); | ||
213 | if (err < 0) | ||
214 | return err; | ||
215 | |||
216 | hw->odr = odr; | 211 | hw->odr = odr; |
217 | 212 | ||
218 | return 0; | 213 | return 0; |
@@ -294,7 +289,8 @@ int hts221_power_on(struct hts221_hw *hw) | |||
294 | { | 289 | { |
295 | int err; | 290 | int err; |
296 | 291 | ||
297 | err = hts221_update_odr(hw, hw->odr); | 292 | err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR, |
293 | HTS221_ENABLE_MASK, true); | ||
298 | if (err < 0) | 294 | if (err < 0) |
299 | return err; | 295 | return err; |
300 | 296 | ||
@@ -627,8 +623,6 @@ int hts221_probe(struct iio_dev *iio_dev) | |||
627 | if (err < 0) | 623 | if (err < 0) |
628 | return err; | 624 | return err; |
629 | 625 | ||
630 | hw->odr = hts221_odr_table[0].hz; | ||
631 | |||
632 | iio_dev->modes = INDIO_DIRECT_MODE; | 626 | iio_dev->modes = INDIO_DIRECT_MODE; |
633 | iio_dev->dev.parent = hw->dev; | 627 | iio_dev->dev.parent = hw->dev; |
634 | iio_dev->available_scan_masks = hts221_scan_masks; | 628 | iio_dev->available_scan_masks = hts221_scan_masks; |
@@ -643,6 +637,10 @@ int hts221_probe(struct iio_dev *iio_dev) | |||
643 | if (err < 0) | 637 | if (err < 0) |
644 | return err; | 638 | return err; |
645 | 639 | ||
640 | err = hts221_update_odr(hw, hts221_odr_table[0].hz); | ||
641 | if (err < 0) | ||
642 | return err; | ||
643 | |||
646 | /* configure humidity sensor */ | 644 | /* configure humidity sensor */ |
647 | err = hts221_parse_rh_caldata(hw); | 645 | err = hts221_parse_rh_caldata(hw); |
648 | if (err < 0) { | 646 | if (err < 0) { |
@@ -706,7 +704,8 @@ static int __maybe_unused hts221_resume(struct device *dev) | |||
706 | int err = 0; | 704 | int err = 0; |
707 | 705 | ||
708 | if (hw->enabled) | 706 | if (hw->enabled) |
709 | err = hts221_update_odr(hw, hw->odr); | 707 | err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR, |
708 | HTS221_ENABLE_MASK, true); | ||
710 | 709 | ||
711 | return err; | 710 | return err; |
712 | } | 711 | } |