Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irda: ali-ircc: Replace timeval with ktime_t

The ali ircc driver uses 'timeval', which we try to remove in the kernel
because all 32-bit time types will break in the year 2038.

This patch also changes do_gettimeofday() to ktime_get() accordingly,
since ktime_get returns a ktime_t, but do_gettimeofday returns a
struct timeval, and the other reason is that ktime_get() uses
the monotonic clock.

This patch uses ktime_us_delta to get the elapsed time, and in this
way it no longer needs to check for the overflow, because
ktime_us_delta returns time difference of microsecond.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Chunyan Zhang and committed by
David S. Miller
9f61e309 270d73c1

+5 -11
+3 -8
drivers/net/irda/ali-ircc.c
··· 1462 1462 if (mtt) 1463 1463 { 1464 1464 /* Check how much time we have used already */ 1465 - do_gettimeofday(&self->now); 1466 - 1467 - diff = self->now.tv_usec - self->stamp.tv_usec; 1465 + diff = ktime_us_delta(ktime_get(), self->stamp); 1468 1466 /* self->stamp is set from ali_ircc_dma_receive_complete() */ 1469 1467 1470 1468 pr_debug("%s(), ******* diff = %d *******\n", 1471 1469 __func__, diff); 1472 - 1473 - if (diff < 0) 1474 - diff += 1000000; 1475 - 1470 + 1476 1471 /* Check if the mtt is larger than the time we have 1477 1472 * already used by all the protocol processing 1478 1473 */ ··· 1879 1884 * reduce the min turn time a bit since we will know 1880 1885 * how much time we have used for protocol processing 1881 1886 */ 1882 - do_gettimeofday(&self->stamp); 1887 + self->stamp = ktime_get(); 1883 1888 1884 1889 skb = dev_alloc_skb(len+1); 1885 1890 if (skb == NULL)
+2 -3
drivers/net/irda/ali-ircc.h
··· 22 22 #ifndef ALI_IRCC_H 23 23 #define ALI_IRCC_H 24 24 25 - #include <linux/time.h> 25 + #include <linux/ktime.h> 26 26 27 27 #include <linux/spinlock.h> 28 28 #include <linux/pm.h> ··· 209 209 210 210 unsigned char rcvFramesOverflow; 211 211 212 - struct timeval stamp; 213 - struct timeval now; 212 + ktime_t stamp; 214 213 215 214 spinlock_t lock; /* For serializing operations */ 216 215