public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Martin Kelly <martin@martingkelly.com>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH 5/5] iio:bmi160:snap timestamp closer to event
Date: Sat, 19 Jan 2019 17:29:25 +0000	[thread overview]
Message-ID: <20190119172925.6dafec11@archlinux> (raw)
In-Reply-To: <20190114035621.5252-6-martin@martingkelly.com>

On Sun, 13 Jan 2019 19:56:21 -0800
Martin Kelly <martin@martingkelly.com> wrote:

> From: Martin Kelly <martin@martingkelly.com>
> 
> Currently, we snap the timestamp after reading from the buffer and
> processing the event. When the IIO poll function is triggered by an
> interrupt,  we can get a slightly more accurate timestamp by snapping it
> prior to reading the data, since the data was already generated prior to
> entering the trigger handler. This is not going to make a huge difference,
> but we might as well improve slightly.
> 
> Signed-off-by: Martin Kelly <martin@martingkelly.com>
Could do better by using the standard iio_pollfunc_store_time
to grab the timestamp in the interrupt handler itself rather than in
it's thread.

There is some argument that we should only do that if we know it's
'our' trigger. If we are triggered by someone else, we might report
a time before when the sample we then read was actually captured.

Still most of the time people will use the devices own trigger, or
be running slowly enough they won't care.

Anyhow, if we are going to argue this makes any sense use the
iio_pollfunc_store_time approach please.

As you will probably guess, this isn't the first device with a
dataready interrupt!
 :)

Jonathan

> ---
>  drivers/iio/imu/bmi160/bmi160_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
> index e119965e64a3..4b4456af0971 100644
> --- a/drivers/iio/imu/bmi160/bmi160_core.c
> +++ b/drivers/iio/imu/bmi160/bmi160_core.c
> @@ -408,6 +408,7 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p)
>  {
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
> +	s64 ts = iio_get_time_ns(indio_dev);
>  	struct bmi160_data *data = iio_priv(indio_dev);
>  	__le16 buf[16];
>  	/* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */
> @@ -423,8 +424,7 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p)
>  		buf[j++] = sample;
>  	}
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, buf,
> -					   iio_get_time_ns(indio_dev));
> +	iio_push_to_buffers_with_timestamp(indio_dev, buf, ts);
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
>  	return IRQ_HANDLED;


  reply	other threads:[~2019-01-19 17:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14  3:56 [PATCH 0/5] iio:bmi160: add drdy interrupt support Martin Kelly
2019-01-14  3:56 ` [PATCH 1/5] iio:bmi160: add SPDX identifiers Martin Kelly
2019-01-19 17:03   ` Jonathan Cameron
2019-01-14  3:56 ` [PATCH 2/5] iio:bmi160: add drdy interrupt support Martin Kelly
2019-01-19 17:17   ` Jonathan Cameron
2019-01-22  2:06     ` Martin Kelly
2019-01-14  3:56 ` [PATCH 3/5] dt-bindings: fix incorrect bmi160 IRQ note Martin Kelly
2019-01-14  3:56 ` [PATCH 4/5] dt-bindings:bmi160: add "BOTH" int pin type Martin Kelly
2019-01-19 17:24   ` Jonathan Cameron
2019-01-14  3:56 ` [PATCH 5/5] iio:bmi160:snap timestamp closer to event Martin Kelly
2019-01-19 17:29   ` Jonathan Cameron [this message]
2019-01-15  2:13 ` [PATCH 0/5] iio:bmi160: add drdy interrupt support Martin Kelly

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=20190119172925.6dafec11@archlinux \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=martin@martingkelly.com \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    /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