OSDN Git Service

[media] staging: media: lirc: Replace timeval with ktime_t in lirc_parallel.c
authorArnd Bergmann <arnd@arndb.de>
Wed, 25 Nov 2015 15:13:26 +0000 (13:13 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 3 Dec 2015 18:21:58 +0000 (16:21 -0200)
commit0dbf41a3c88e229009a9f5fd2a89835569fa3451
treeb5ad17a3044139fe1449abe4c19181cd241df34c
parentf07c73fea2187997552020c3d2db4f0b0302931c
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_parallel.c

'struct timeval tv' and 'struct timeval now' is used to calculate the
elapsed time. 'LIRC_SFH506_DELAY' is a delay t_phl in usecs.

32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the lirc_parallel.c file of  media: lirc driver
to use ktime_t.

ktime_get() is  better than using do_gettimeofday(),
because it uses the monotonic clock. ktime_sub is used
to subtract two ktime variables. ktime_to_us() is used to
convert ktime to microsecond.

New ktime_t variable timeout, is added in lirc_off(),to improve
clarity. Introduced a new ktime_t variable in lirc_lirc_irq_handler()
function, to avoid the use of signal variable for storing
seconds in the first part of this function as later it uses
a time unit that is defined by the global "timer" variable.
This makes it more clear.

ktime_set() is used to set a value in seconds to a value in
nanosecond so that ktime_compare() can be used appropriately.
ktime_compare() is used to compare two ktime values.
ktime_add_ns() is used to increment a ktime value by 1 sec.

One comment is also shifted a line up, as it was creating a 80
character warning.

Build tested it. Also tested it with sparse.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/staging/media/lirc/lirc_parallel.c