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

staging: gdm72xx: Replace timeval with ktime_t

struct sdu_stamp in the gdm_sdio.h is a timeval type.
'struct timeval now' is used for calculating elapsed time.

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 gdm72xx driver to use ktime_t.

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

Build tested this by saying Y to WIMAX_GDM72XX.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Arnd Bergmann and committed by
Greg Kroah-Hartman
2bc29a1a 02c34ccc

+8 -9
+6 -7
drivers/staging/gdm72xx/gdm_sdio.c
··· 36 36 #define RX_BUF_SIZE (25*1024) 37 37 38 38 #define TX_HZ 2000 39 - #define TX_INTERVAL (1000000/TX_HZ) 39 + #define TX_INTERVAL (NSEC_PER_SEC/TX_HZ) 40 40 41 41 static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx) 42 42 { ··· 303 303 put_tx_struct(t->tx_cxt, t); 304 304 } 305 305 306 - do_gettimeofday(&tx->sdu_stamp); 306 + tx->sdu_stamp = ktime_get(); 307 307 spin_unlock_irqrestore(&tx->lock, flags); 308 308 } 309 309 ··· 330 330 struct sdio_func *func = sdev->func; 331 331 struct tx_cxt *tx = &sdev->tx; 332 332 struct sdio_tx *t = NULL; 333 - struct timeval now, *before; 333 + ktime_t now, before; 334 334 int is_sdu = 0; 335 335 long diff; 336 336 unsigned long flags; ··· 346 346 list_del(&t->list); 347 347 is_sdu = 0; 348 348 } else if (!tx->stop_sdu_tx && !list_empty(&tx->sdu_list)) { 349 - do_gettimeofday(&now); 350 - before = &tx->sdu_stamp; 349 + now = ktime_get(); 350 + before = tx->sdu_stamp; 351 351 352 - diff = (now.tv_sec - before->tv_sec) * 1000000 + 353 - (now.tv_usec - before->tv_usec); 352 + diff = ktime_to_ns(ktime_sub(now, before)); 354 353 if (diff >= 0 && diff < TX_INTERVAL) { 355 354 schedule_work(&sdev->ws); 356 355 spin_unlock_irqrestore(&tx->lock, flags);
+2 -2
drivers/staging/gdm72xx/gdm_sdio.h
··· 15 15 #define __GDM72XX_GDM_SDIO_H__ 16 16 17 17 #include <linux/types.h> 18 - #include <linux/time.h> 18 + #include <linux/ktime.h> 19 19 20 20 #define MAX_NR_SDU_BUF 64 21 21 ··· 32 32 struct list_head free_list; 33 33 struct list_head sdu_list; 34 34 struct list_head hci_list; 35 - struct timeval sdu_stamp; 35 + ktime_t sdu_stamp; 36 36 u8 *sdu_buf; 37 37 spinlock_t lock; 38 38 int can_send;