diff options
author | Tina Ruchandani <ruchandani.tina@gmail.com> | 2015-10-29 03:16:57 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-11-19 06:31:45 -0500 |
commit | dd4c22a61e0bdaf84202fcf84cb8f75ed7bb3552 (patch) | |
tree | 7cef248203e463111c0dae2ff1cb2d47aae528d8 | |
parent | 8c47311d34eccedb06bc60fc9435a53bd4aff392 (diff) |
[media] rc-core: Remove 'struct timeval' usage
streamzap uses 'struct timeval' to store the start time of a signal for
gap tracking. struct timeval uses a 32-bit seconds representation which
will overflow in year 2038 and beyond. Replace struct timeval with ktime_t
which uses a 64-bit seconds representation and is 2038 safe. This patch
uses ktime_get_real() preserving the use of wall-clock time in the
original code.
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/rc/streamzap.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c index 5a17cb88ff27..815243c65bc3 100644 --- a/drivers/media/rc/streamzap.c +++ b/drivers/media/rc/streamzap.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/device.h> | 34 | #include <linux/device.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/ktime.h> | ||
37 | #include <linux/usb.h> | 38 | #include <linux/usb.h> |
38 | #include <linux/usb/input.h> | 39 | #include <linux/usb/input.h> |
39 | #include <media/rc-core.h> | 40 | #include <media/rc-core.h> |
@@ -96,8 +97,8 @@ struct streamzap_ir { | |||
96 | /* sum of signal lengths received since signal start */ | 97 | /* sum of signal lengths received since signal start */ |
97 | unsigned long sum; | 98 | unsigned long sum; |
98 | /* start time of signal; necessary for gap tracking */ | 99 | /* start time of signal; necessary for gap tracking */ |
99 | struct timeval signal_last; | 100 | ktime_t signal_last; |
100 | struct timeval signal_start; | 101 | ktime_t signal_start; |
101 | bool timeout_enabled; | 102 | bool timeout_enabled; |
102 | 103 | ||
103 | char name[128]; | 104 | char name[128]; |
@@ -136,20 +137,18 @@ static void sz_push_full_pulse(struct streamzap_ir *sz, | |||
136 | DEFINE_IR_RAW_EVENT(rawir); | 137 | DEFINE_IR_RAW_EVENT(rawir); |
137 | 138 | ||
138 | if (sz->idle) { | 139 | if (sz->idle) { |
139 | long deltv; | 140 | int delta; |
140 | 141 | ||
141 | sz->signal_last = sz->signal_start; | 142 | sz->signal_last = sz->signal_start; |
142 | do_gettimeofday(&sz->signal_start); | 143 | sz->signal_start = ktime_get_real(); |
143 | 144 | ||
144 | deltv = sz->signal_start.tv_sec - sz->signal_last.tv_sec; | 145 | delta = ktime_us_delta(sz->signal_start, sz->signal_last); |
145 | rawir.pulse = false; | 146 | rawir.pulse = false; |
146 | if (deltv > 15) { | 147 | if (delta > (15 * USEC_PER_SEC)) { |
147 | /* really long time */ | 148 | /* really long time */ |
148 | rawir.duration = IR_MAX_DURATION; | 149 | rawir.duration = IR_MAX_DURATION; |
149 | } else { | 150 | } else { |
150 | rawir.duration = (int)(deltv * 1000000 + | 151 | rawir.duration = delta; |
151 | sz->signal_start.tv_usec - | ||
152 | sz->signal_last.tv_usec); | ||
153 | rawir.duration -= sz->sum; | 152 | rawir.duration -= sz->sum; |
154 | rawir.duration = US_TO_NS(rawir.duration); | 153 | rawir.duration = US_TO_NS(rawir.duration); |
155 | rawir.duration = (rawir.duration > IR_MAX_DURATION) ? | 154 | rawir.duration = (rawir.duration > IR_MAX_DURATION) ? |
@@ -428,7 +427,7 @@ static int streamzap_probe(struct usb_interface *intf, | |||
428 | sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); | 427 | sz->max_timeout = US_TO_NS(SZ_TIMEOUT * SZ_RESOLUTION); |
429 | #endif | 428 | #endif |
430 | 429 | ||
431 | do_gettimeofday(&sz->signal_start); | 430 | sz->signal_start = ktime_get_real(); |
432 | 431 | ||
433 | /* Complete final initialisations */ | 432 | /* Complete final initialisations */ |
434 | usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, | 433 | usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, |