diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-11-10 10:58:26 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-12-04 20:32:53 -0500 |
commit | bc8f91665b3f2fd94b80217e433dc90383e75ae4 (patch) | |
tree | 801a19c305b6d0ea10904a9d680cd5ab0d7b623c /drivers/scsi/3w-9xxx.c | |
parent | 9c88673f9d855899d640473a411a17f25eff45d8 (diff) |
scsi: 3ware: use 64-bit times for FW time sync
The calculation of the number of seconds since Sunday 00:00:00 overflows
in 2106, meaning that we instead will return the seconds since Wednesday
06:28:16 afterwards.
Using 64-bit time stamps avoids this slight inconsistency, and the
deprecated do_gettimeofday(), replacing it with the simpler
ktime_get_real_seconds().
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Adam Radford <aradford@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/3w-9xxx.c')
-rw-r--r-- | drivers/scsi/3w-9xxx.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index cb9af3f7b653..b1c9bd9c1bfd 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -472,11 +472,10 @@ out: | |||
472 | static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) | 472 | static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) |
473 | { | 473 | { |
474 | u32 schedulertime; | 474 | u32 schedulertime; |
475 | struct timeval utc; | ||
476 | TW_Command_Full *full_command_packet; | 475 | TW_Command_Full *full_command_packet; |
477 | TW_Command *command_packet; | 476 | TW_Command *command_packet; |
478 | TW_Param_Apache *param; | 477 | TW_Param_Apache *param; |
479 | u32 local_time; | 478 | time64_t local_time; |
480 | 479 | ||
481 | /* Fill out the command packet */ | 480 | /* Fill out the command packet */ |
482 | full_command_packet = tw_dev->command_packet_virt[request_id]; | 481 | full_command_packet = tw_dev->command_packet_virt[request_id]; |
@@ -498,9 +497,8 @@ static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) | |||
498 | 497 | ||
499 | /* Convert system time in UTC to local time seconds since last | 498 | /* Convert system time in UTC to local time seconds since last |
500 | Sunday 12:00AM */ | 499 | Sunday 12:00AM */ |
501 | do_gettimeofday(&utc); | 500 | local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60)); |
502 | local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60)); | 501 | div_u64_rem(local_time - (3 * 86400), 604800, &schedulertime); |
503 | schedulertime = local_time - (3 * 86400); | ||
504 | schedulertime = cpu_to_le32(schedulertime % 604800); | 502 | schedulertime = cpu_to_le32(schedulertime % 604800); |
505 | 503 | ||
506 | memcpy(param->data, &schedulertime, sizeof(u32)); | 504 | memcpy(param->data, &schedulertime, sizeof(u32)); |