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 <amitoj1...@gmail.com>
---
Changes in v2:
        -Removed trailing whitespace

 drivers/staging/media/lirc/lirc_sasem.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_sasem.c 
b/drivers/staging/media/lirc/lirc_sasem.c
index bc78da0..37f9997 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -38,6 +38,7 @@
 
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/ktime.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/uaccess.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,9 +585,7 @@ 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;
+       ms = ktime_ms_delta(timestamp, context->presstime);
 
        if (memcmp(buf, "\x08\0\0\0\0\0\0\0", 8) == 0) {
                /*
@@ -602,8 +601,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 +611,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);
-- 
1.9.1

_______________________________________________
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038

Reply via email to