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.
Signed-off-by: Amitoj Kaur Chawla amitoj1606@gmail.com --- drivers/staging/media/lirc/lirc_sasem.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index bc78da0..51780c0 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -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);
On Sat, Oct 24, 2015 at 11:49:42PM +0530, Amitoj Kaur Chawla wrote:
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.
Signed-off-by: Amitoj Kaur Chawla amitoj1606@gmail.com
drivers/staging/media/lirc/lirc_sasem.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
<snip>
@@ -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