From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: sean@geanix.com, linux-iio@vger.kernel.org, lorenzo.bianconi@redhat.com
Subject: Re: [PATCH v2] iio: imu: st_lsm6dsx: reset hw ts after resume
Date: Mon, 20 Jul 2020 12:46:37 +0100 [thread overview]
Message-ID: <20200720124637.4f2dcabb@archlinux> (raw)
In-Reply-To: <4eb556ec9e68dccde35fa01fddad252a746a2fd3.1594640279.git.lorenzo@kernel.org>
On Mon, 13 Jul 2020 13:40:19 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Reset hw time samples generator after system resume in order to avoid
> disalignment between system and device time reference since FIFO
> batching and time samples generator are disabled during suspend.
>
> Fixes: 213451076bd3 ("iio: imu: st_lsm6dsx: add hw timestamp support")
> Tested-by: Sean Nyekjaer <sean@geanix.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Applied to the fixes-togreg branch of iio.git. I may well yank this
into the togreg branch if I get a pull out later this week.
That will probably hit mainline faster than the fixes branch.
> ---
> Changes since v1:
> - add missing Fixes tag
> - improve commit log
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 +--
> .../iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 23 ++++++++++++-------
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
> 3 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index b56df409ed0f..529970195b39 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -436,8 +436,7 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
> u16 watermark);
> int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable);
> int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
> -int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> - enum st_lsm6dsx_fifo_mode fifo_mode);
> +int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw);
> int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw);
> int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw);
> int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u32 odr, u8 *val);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index afd00daeefb2..7de10bd636ea 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -184,8 +184,8 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
> return err;
> }
>
> -int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> - enum st_lsm6dsx_fifo_mode fifo_mode)
> +static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> + enum st_lsm6dsx_fifo_mode fifo_mode)
> {
> unsigned int data;
>
> @@ -302,6 +302,18 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw)
> return 0;
> }
>
> +int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw)
> +{
> + int err;
> +
> + /* reset hw ts counter */
> + err = st_lsm6dsx_reset_hw_ts(hw);
> + if (err < 0)
> + return err;
> +
> + return st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
> +}
> +
> /*
> * Set max bulk read to ST_LSM6DSX_MAX_WORD_LEN/ST_LSM6DSX_MAX_TAGGED_WORD_LEN
> * in order to avoid a kmalloc for each bus access
> @@ -675,12 +687,7 @@ int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
> goto out;
>
> if (fifo_mask) {
> - /* reset hw ts counter */
> - err = st_lsm6dsx_reset_hw_ts(hw);
> - if (err < 0)
> - goto out;
> -
> - err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
> + err = st_lsm6dsx_resume_fifo(hw);
> if (err < 0)
> goto out;
> }
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index c8ddeb3f48ff..346c24281d26 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2457,7 +2457,7 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
> }
>
> if (hw->fifo_mask)
> - err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
> + err = st_lsm6dsx_resume_fifo(hw);
>
> return err;
> }
prev parent reply other threads:[~2020-07-20 11:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 11:40 [PATCH v2] iio: imu: st_lsm6dsx: reset hw ts after resume Lorenzo Bianconi
2020-07-20 11:46 ` Jonathan Cameron [this message]
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=20200720124637.4f2dcabb@archlinux \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=lorenzo@kernel.org \
--cc=sean@geanix.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).