Skip to content

Commit 2ae4b6b

Browse files
musicakcStefan Richter
authored andcommitted
firewire: nosy: Replace timeval with timespec64
32 bit systems using 'struct timeval' will break in the year 2038, so we replace the code appropriately. However, this driver is not broken in 2038 since we are using only the microseconds portion of the current time. This patch replaces timeval with timespec64. Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 100ceb6 commit 2ae4b6b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎drivers/firewire/nosy.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/sched.h> /* required for linux/wait.h */
3434
#include <linux/slab.h>
3535
#include <linux/spinlock.h>
36+
#include <linux/time64.h>
3637
#include <linux/timex.h>
3738
#include <linux/uaccess.h>
3839
#include <linux/wait.h>
@@ -413,17 +414,18 @@ static void
413414
packet_irq_handler(struct pcilynx *lynx)
414415
{
415416
struct client *client;
416-
u32 tcode_mask, tcode;
417+
u32 tcode_mask, tcode, timestamp;
417418
size_t length;
418-
struct timeval tv;
419+
struct timespec64 ts64;
419420

420421
/* FIXME: Also report rcv_speed. */
421422

422423
length = __le32_to_cpu(lynx->rcv_pcl->pcl_status) & 0x00001fff;
423424
tcode = __le32_to_cpu(lynx->rcv_buffer[1]) >> 4 & 0xf;
424425

425-
do_gettimeofday(&tv);
426-
lynx->rcv_buffer[0] = (__force __le32)tv.tv_usec;
426+
ktime_get_real_ts64(&ts64);
427+
timestamp = ts64.tv_nsec / NSEC_PER_USEC;
428+
lynx->rcv_buffer[0] = (__force __le32)timestamp;
427429

428430
if (length == PHY_PACKET_SIZE)
429431
tcode_mask = 1 << TCODE_PHY_PACKET;

0 commit comments

Comments
 (0)