staging: media: lirc: lirc_sasem: Replace timeval with ktime_t
Subsystems (2)
PATCH 1/1 staging: media: lirc: lirc_sasem: Replace timeval with ktime_t
This driver uses 'struct timeval' which we are trying to remove since 32 bit time types will break in the year 2038 by replacing it with ktime_t.
This patch changes do_gettimeofday() to ktime_get() because ktime_get() returns ktime_t while do_gettimeofday() returns struct timeval.
This patch also uses ktime_ms_delta() to get the elapsed time in milliseconds.
--- drivers/staging/media/lirc/lirc_sasem.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/media/lirc/lirc_sasem.c +8 -10
@@ -40,6 +40,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> +#include <linux/ktime.h> #include <linux/uaccess.h> #include <linux/usb.h>
@@ -111,7 +112,7 @@ struct sasem_context { } tx;/* for dealing with repeat codes (wish there was a toggle bit!) */ -struct timeval presstime; +ktime_t presstime;char lastcode[8 ];int codesaved; };
@@ -567,7 +568,7 @@ static void incoming_packet(struct sasem_context *context,int len = urb->actual_length;unsigned char *buf = urb->transfer_buffer;long ms; -struct timeval tv; +ktime_t timestamp;if (len !=8 ) { dev_warn(&context->dev->dev,
@@ -584,10 +585,9 @@ static void incoming_packet(struct sasem_context *context,*/ /* get the time since the last button press */ -do_gettimeofday (&tv); - ms = (tv.tv_sec - context->presstime.tv_sec) *1000 + - (tv.tv_usec - context->presstime.tv_usec) /1000 ; - + timestamp =ktime_get (); + ms =ktime_ms_delta (timestamp, context->presstime); +if (memcmp (buf,"\x08\0\0\0\0\0\0\0" ,8 ) ==0 ) {/* * the repeat code is being sent, so we copy
@@ -602,8 +602,7 @@ static void incoming_packet(struct sasem_context *context,*/ if ((ms <250 ) && (context->codesaved !=0 )) {memcpy (buf, &context->lastcode,8 ); - context->presstime.tv_sec = tv.tv_sec; - context->presstime.tv_usec = tv.tv_usec; + context->presstime = timestamp; } }else {/* save the current valid code for repeats */
@@ -613,8 +612,7 @@ static void incoming_packet(struct sasem_context *context,* just for safety reasons */ context->codesaved =1 ; - context->presstime.tv_sec = tv.tv_sec; - context->presstime.tv_usec = tv.tv_usec; + context->presstime = timestamp; }lirc_buffer_write (context->driver->rbuf, buf);
Signature · 1 line
1.9.1
Quoted 16 lines · Amitoj Kaur Chawla
This driver uses 'struct timeval' which we are trying to remove since 32 bit time types will break in the year 2038 by replacing it with
ktime_t.This patch changes
do_gettimeofday()toktime_get()becausektime_get()returnsktime_twhiledo_gettimeofday()returns struct timeval.This patch also uses
ktime_ms_delta()to get the elapsed time in milliseconds.Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/media/lirc/lirc_sasem.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
<snip>
drivers/staging/media/lirc/lirc_sasem.c static void incoming_packet(struct sasem_context *context, · line 590
Quoted 11 lines
drivers/staging/media/lirc/lirc_sasem.c +3
-4@@ -584,10 +585,9 @@ static void incoming_packet(struct sasem_context *context,*/ /* get the time since the last button press */ -do_gettimeofday (&tv); - ms = (tv.tv_sec - context->presstime.tv_sec) *1000 + - (tv.tv_usec - context->presstime.tv_usec) /1000 ; - + timestamp =ktime_get (); + ms =ktime_ms_delta (timestamp, context->presstime); +
Trailing whitespace.
regards
sudip