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

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>
---
 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. */
-- 
2.26.2


  reply	other threads:[~2020-11-30 13:00 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 ` Linus Walleij [this message]
2020-11-30 21:07   ` [PATCH 2/2] iio: gyro: mpu3050: Store timestamp in poll function Jonathan Cameron
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=20201130125915.1315667-2-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --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).