Re: [PATCH 2/2] iio: gyro: mpu3050: Store timestamp in poll function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 30 Nov 2020 13:59:15 +0100
Linus Walleij <linus.walleij@xxxxxxxxxx> 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@xxxxxxxxxx>
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. */




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux