From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
lorenzo.bianconi@st.com
Subject: Re: [PATCH 4/9] iio: humidity: hts221: avoid useless ODR reconfiguration
Date: Sun, 9 Jul 2017 19:32:08 +0100 [thread overview]
Message-ID: <20170709193208.6864b158@kernel.org> (raw)
In-Reply-To: <20170709165704.26311-5-lorenzo.bianconi@st.com>
On Sun, 9 Jul 2017 18:56:59 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> Configure sensor ODR just in hts221_write_raw() in order to avoid
> to set device sample rate multiple times.
> Squash hts221_power_off()/hts221_power_on() in hts221_set_enable()
Two changes = two patches please.
Actual contents for each looks fine.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
> drivers/iio/humidity/hts221.h | 3 +--
> drivers/iio/humidity/hts221_buffer.c | 4 ++--
> drivers/iio/humidity/hts221_core.c | 37 +++++++++++-------------------------
> 3 files changed, 14 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/iio/humidity/hts221.h b/drivers/iio/humidity/hts221.h
> index 94510266e0a5..7b5691a6df53 100644
> --- a/drivers/iio/humidity/hts221.h
> +++ b/drivers/iio/humidity/hts221.h
> @@ -68,8 +68,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);
>
> diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
> index 7d19a3da7ab7..c4ed153ad397 100644
> --- a/drivers/iio/humidity/hts221_buffer.c
> +++ b/drivers/iio/humidity/hts221_buffer.c
> @@ -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 = {
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index b36734b8070e..7d30e2594a58 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -207,11 +207,6 @@ static int hts221_update_odr(struct hts221_hw *hw, u8 odr)
> if (err < 0)
> return err;
>
> - err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
> - HTS221_ENABLE_MASK, 1);
> - if (err < 0)
> - return err;
> -
> hw->odr = odr;
>
> return 0;
> @@ -290,29 +285,16 @@ hts221_sysfs_temp_oversampling_avail(struct device *dev,
> return len;
> }
>
> -int hts221_power_on(struct hts221_hw *hw)
> -{
> - int err;
> -
> - err = hts221_update_odr(hw, hw->odr);
> - if (err < 0)
> - return err;
> -
> - hw->enabled = true;
> -
> - return 0;
> -}
> -
> -int hts221_power_off(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, false);
> + HTS221_ENABLE_MASK, enable);
> if (err < 0)
> return err;
>
> - hw->enabled = false;
> + hw->enabled = enable;
>
> return 0;
> }
> @@ -467,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;
>
> @@ -477,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);
>
> @@ -627,8 +609,6 @@ int hts221_probe(struct iio_dev *iio_dev)
> if (err < 0)
> return err;
>
> - hw->odr = hts221_odr_table[0].hz;
> -
> iio_dev->modes = INDIO_DIRECT_MODE;
> iio_dev->dev.parent = hw->dev;
> iio_dev->available_scan_masks = hts221_scan_masks;
> @@ -643,6 +623,10 @@ int hts221_probe(struct iio_dev *iio_dev)
> if (err < 0)
> return err;
>
> + err = hts221_update_odr(hw, hts221_odr_table[0].hz);
> + if (err < 0)
> + return err;
> +
> /* configure humidity sensor */
> err = hts221_parse_rh_caldata(hw);
> if (err < 0) {
> @@ -706,7 +690,8 @@ static int __maybe_unused hts221_resume(struct device *dev)
> int err = 0;
>
> 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;
> }
next prev parent reply other threads:[~2017-07-09 18:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-09 16:56 [PATCH 0/9] hts221: add new features and fix power-off procedure Lorenzo Bianconi
2017-07-09 16:56 ` [PATCH 1/9] iio: humidity: hts221: refactor write_with_mask code Lorenzo Bianconi
2017-07-09 18:28 ` Jonathan Cameron
2017-07-09 21:18 ` Lorenzo Bianconi
2017-07-10 20:47 ` Jonathan Cameron
2017-07-09 16:56 ` [PATCH 2/9] iio: humidity: hts221: move BDU configuration in probe routine Lorenzo Bianconi
2017-07-09 18:29 ` Jonathan Cameron
2017-07-09 16:56 ` [PATCH 3/9] iio: humidity: hts221: do not overwrite reserved data during power-down Lorenzo Bianconi
2017-07-09 18:30 ` Jonathan Cameron
2017-07-09 21:26 ` Lorenzo Bianconi
2017-07-09 16:56 ` [PATCH 4/9] iio: humidity: hts221: avoid useless ODR reconfiguration Lorenzo Bianconi
2017-07-09 18:32 ` Jonathan Cameron [this message]
2017-07-09 21:27 ` Lorenzo Bianconi
2017-07-09 16:57 ` [PATCH 5/9] iio: humidity: hts221: support active-low interrupts Lorenzo Bianconi
2017-07-09 18:39 ` Jonathan Cameron
2017-07-10 9:36 ` Marc Zyngier
2017-07-11 18:52 ` Jonathan Cameron
2017-07-09 16:57 ` [PATCH 6/9] dt-bindings: " Lorenzo Bianconi
2017-07-11 2:49 ` Rob Herring
2017-07-09 16:57 ` [PATCH 7/9] iio: humidity: hts221: support open drain mode Lorenzo Bianconi
2017-07-09 16:57 ` [PATCH 8/9] dt-bindings: " Lorenzo Bianconi
2017-07-11 2:51 ` Rob Herring
2017-07-11 18:26 ` Jonathan Cameron
2017-07-11 18:42 ` Rob Herring
2017-07-11 18:56 ` Jonathan Cameron
2017-07-15 14:32 ` Lorenzo Bianconi
2017-07-17 11:49 ` Jonathan Cameron
2017-07-09 16:57 ` [PATCH 9/9] iio: humidity: hts221: move drdy enable logic in hts221_trig_set_state() Lorenzo Bianconi
2017-07-09 18:41 ` Jonathan Cameron
2017-07-09 21:28 ` Lorenzo Bianconi
2017-07-16 9:45 ` Lorenzo Bianconi
2017-07-16 19:50 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170709193208.6864b158@kernel.org \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=lorenzo.bianconi@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).