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

irda: stir4200: Replace timeval with ktime_t

The stir4200 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 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
89a07e17 4c3bd197

+7 -9
+7 -9
drivers/net/irda/stir4200.c
··· 40 40 #include <linux/moduleparam.h> 41 41 42 42 #include <linux/kernel.h> 43 + #include <linux/ktime.h> 43 44 #include <linux/types.h> 44 45 #include <linux/time.h> 45 46 #include <linux/skbuff.h> ··· 175 174 __u8 *fifo_status; 176 175 177 176 iobuff_t rx_buff; /* receive unwrap state machine */ 178 - struct timeval rx_time; 177 + ktime_t rx_time; 179 178 int receiving; 180 179 struct urb *rx_urb; 181 180 }; ··· 651 650 static void turnaround_delay(const struct stir_cb *stir, long us) 652 651 { 653 652 long ticks; 654 - struct timeval now; 655 653 656 654 if (us <= 0) 657 655 return; 658 656 659 - do_gettimeofday(&now); 660 - if (now.tv_sec - stir->rx_time.tv_sec > 0) 661 - us -= USEC_PER_SEC; 662 - us -= now.tv_usec - stir->rx_time.tv_usec; 657 + us -= ktime_us_delta(ktime_get(), stir->rx_time); 658 + 663 659 if (us < 10) 664 660 return; 665 661 ··· 821 823 pr_debug("receive %d\n", urb->actual_length); 822 824 unwrap_chars(stir, urb->transfer_buffer, 823 825 urb->actual_length); 824 - 825 - do_gettimeofday(&stir->rx_time); 826 + 827 + stir->rx_time = ktime_get(); 826 828 } 827 829 828 830 /* kernel thread is stopping receiver don't resubmit */ ··· 874 876 875 877 skb_reserve(stir->rx_buff.skb, 1); 876 878 stir->rx_buff.head = stir->rx_buff.skb->data; 877 - do_gettimeofday(&stir->rx_time); 879 + stir->rx_time = ktime_get(); 878 880 879 881 stir->rx_urb = usb_alloc_urb(0, GFP_KERNEL); 880 882 if (!stir->rx_urb)