linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH 2/2] iio: gyro: mpu3050: Store timestamp in poll function
Date: Mon, 30 Nov 2020 21:07:52 +0000	[thread overview]
Message-ID: <20201130210752.5028588c@archlinux> (raw)
In-Reply-To: <20201130125915.1315667-2-linus.walleij@linaro.org>

On Mon, 30 Nov 2020 13:59:15 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:

> If something other than the MPU3050 itself is using this
> trigger, the timestamp needs to be stored in the poll
> function.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
I'm a bit confused here.

pollfuncs are per device using the trigger, so writing to the
timestamp of the one from this device, won't have an affect on
any others.

If it did, we'd still have an issue as there are no ordering
guarantees amongst different consumers of a trigger.

Jonathan

> ---
>  drivers/iio/gyro/mpu3050-core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
> index 0d0850945d3a..b892487394ea 100644
> --- a/drivers/iio/gyro/mpu3050-core.c
> +++ b/drivers/iio/gyro/mpu3050-core.c
> @@ -457,7 +457,7 @@ static int mpu3050_write_raw(struct iio_dev *indio_dev,
>  
>  static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
>  {
> -	const struct iio_poll_func *pf = p;
> +	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct mpu3050 *mpu3050 = iio_priv(indio_dev);
>  	int ret;
> @@ -482,6 +482,9 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
>  	else
>  		timestamp = iio_get_time_ns(indio_dev);
>  
> +	/* Someone else may be using us as trigger */
> +	pf->timestamp = timestamp;
> +
>  	mutex_lock(&mpu3050->lock);
>  
>  	/* Using the hardware IRQ trigger? Check the buffer then. */


  reply	other threads:[~2020-11-30 21:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 12:59 [PATCH 1/2] iio: gyro: mpu3050: Use devm_ to set up buffer Linus Walleij
2020-11-30 12:59 ` [PATCH 2/2] iio: gyro: mpu3050: Store timestamp in poll function Linus Walleij
2020-11-30 21:07   ` Jonathan Cameron [this message]
2020-12-01 12:41     ` Linus Walleij
2020-11-30 20:51 ` [PATCH 1/2] iio: gyro: mpu3050: Use devm_ to set up buffer 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=20201130210752.5028588c@archlinux \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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).