diff mbox series

[1/1] iio: accel: kionix-kx022a: Get the timestamp from the driver's private data in the trigger_handler

Message ID d81610c45af55b1c5eab5d0597f71650ff908203.1676661174.git.mehdi.djait.k@gmail.com (mailing list archive)
State Superseded
Headers show
Series iio: accel: kionix-kx022a: Timestamp minor fix | expand

Commit Message

Mehdi Djait Feb. 17, 2023, 7:19 p.m. UTC
The trigger_handler gets called from the IRQ thread handler using
iio_trigger_poll_chained() which will only call the bottom half of the
pollfunc and therefore pf->timestamp will not get set.

Use instead the timestamp from the driver's private data which is always
set in the IRQ handler.

Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
---
 drivers/iio/accel/kionix-kx022a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matti Vaittinen Feb. 17, 2023, 7:52 p.m. UTC | #1
On 2/17/23 21:19, Mehdi Djait wrote:
> The trigger_handler gets called from the IRQ thread handler using
> iio_trigger_poll_chained() which will only call the bottom half of the
> pollfunc and therefore pf->timestamp will not get set.
> 
> Use instead the timestamp from the driver's private data which is always
> set in the IRQ handler.
> 
> Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/accel/kionix-kx022a.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
> index f866859855cd..1c3a72380fb8 100644
> --- a/drivers/iio/accel/kionix-kx022a.c
> +++ b/drivers/iio/accel/kionix-kx022a.c
> @@ -864,7 +864,7 @@ static irqreturn_t kx022a_trigger_handler(int irq, void *p)
>   	if (ret < 0)
>   		goto err_read;
>   
> -	iio_push_to_buffers_with_timestamp(idev, data->buffer, pf->timestamp);
> +	iio_push_to_buffers_with_timestamp(idev, data->buffer, data->timestamp);
>   err_read:
>   	iio_trigger_notify_done(idev->trig);
>
Matti Vaittinen Feb. 17, 2023, 7:55 p.m. UTC | #2
On 2/17/23 21:52, Matti Vaittinen wrote:
> On 2/17/23 21:19, Mehdi Djait wrote:
>> The trigger_handler gets called from the IRQ thread handler using
>> iio_trigger_poll_chained() which will only call the bottom half of the
>> pollfunc and therefore pf->timestamp will not get set.
>>
>> Use instead the timestamp from the driver's private data which is always
>> set in the IRQ handler.
>>
>> Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
> 
> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
> 

Oh. I just noticed there is no Fixes tag. It'd be good to have one as it 
usually helps fixes like this being back-ported to stable.

>> ---
>>   drivers/iio/accel/kionix-kx022a.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/accel/kionix-kx022a.c 
>> b/drivers/iio/accel/kionix-kx022a.c
>> index f866859855cd..1c3a72380fb8 100644
>> --- a/drivers/iio/accel/kionix-kx022a.c
>> +++ b/drivers/iio/accel/kionix-kx022a.c
>> @@ -864,7 +864,7 @@ static irqreturn_t kx022a_trigger_handler(int irq, 
>> void *p)
>>       if (ret < 0)
>>           goto err_read;
>> -    iio_push_to_buffers_with_timestamp(idev, data->buffer, 
>> pf->timestamp);
>> +    iio_push_to_buffers_with_timestamp(idev, data->buffer, 
>> data->timestamp);
>>   err_read:
>>       iio_trigger_notify_done(idev->trig);
>
Mehdi Djait Feb. 18, 2023, 1:17 p.m. UTC | #3
Hi Matti,

On Fri, Feb 17, 2023 at 09:55:33PM +0200, Matti Vaittinen wrote:
> On 2/17/23 21:52, Matti Vaittinen wrote:
> > On 2/17/23 21:19, Mehdi Djait wrote:
> > > The trigger_handler gets called from the IRQ thread handler using
> > > iio_trigger_poll_chained() which will only call the bottom half of the
> > > pollfunc and therefore pf->timestamp will not get set.
> > > 
> > > Use instead the timestamp from the driver's private data which is always
> > > set in the IRQ handler.
> > > 
> > > Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
> > 
> > Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
> > 
> 
> Oh. I just noticed there is no Fixes tag. It'd be good to have one as it
> usually helps fixes like this being back-ported to stable.
> 

I will add the Fixes tag and send the patch again.

--
Kind Regards
Mehdi Djait
diff mbox series

Patch

diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
index f866859855cd..1c3a72380fb8 100644
--- a/drivers/iio/accel/kionix-kx022a.c
+++ b/drivers/iio/accel/kionix-kx022a.c
@@ -864,7 +864,7 @@  static irqreturn_t kx022a_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto err_read;
 
-	iio_push_to_buffers_with_timestamp(idev, data->buffer, pf->timestamp);
+	iio_push_to_buffers_with_timestamp(idev, data->buffer, data->timestamp);
 err_read:
 	iio_trigger_notify_done(idev->trig);