32-bit systems using struct timeval will break in the year 2038, so we have to replace that code with more appropriate types. ktime_get() is better than using do_gettimeofday(), because it uses the monotonic clock. ktime_to_us() is used to convert ktime to microseconds.
Signed-off-by: Ksenija Stanojevic ksenija.stanojevic@gmail.com --- drivers/staging/rts5208/rtsx.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h index 9e6ecb7..5c79d7d 100644 --- a/drivers/staging/rts5208/rtsx.h +++ b/drivers/staging/rts5208/rtsx.h @@ -37,7 +37,7 @@ #include <linux/cdrom.h> #include <linux/workqueue.h> #include <linux/timer.h> -#include <linux/time.h> +#include <linux/ktime.h>
#include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> @@ -151,21 +151,17 @@ static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host)
static inline void get_current_time(u8 *timeval_buf, int buf_len) { - struct timeval tv; + u64 us;
- if (!timeval_buf || (buf_len < 8)) + if (!timeval_buf || (buf_len < 4)) return;
- do_gettimeofday(&tv); + us = ktime_to_us(ktime_get());
- timeval_buf[0] = (u8)(tv.tv_sec >> 24); - timeval_buf[1] = (u8)(tv.tv_sec >> 16); - timeval_buf[2] = (u8)(tv.tv_sec >> 8); - timeval_buf[3] = (u8)(tv.tv_sec); - timeval_buf[4] = (u8)(tv.tv_usec >> 24); - timeval_buf[5] = (u8)(tv.tv_usec >> 16); - timeval_buf[6] = (u8)(tv.tv_usec >> 8); - timeval_buf[7] = (u8)(tv.tv_usec); + timeval_buf[0] = (u8)(us >> 24); + timeval_buf[1] = (u8)(us >> 16); + timeval_buf[2] = (u8)(us >> 8); + timeval_buf[3] = (u8)(us); }
/* The scsi_lock() and scsi_unlock() macros protect the sm_state and the