summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/3w-sas.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-11-10 16:58:26 +0100
committerMartin K. Petersen <martin.petersen@oracle.com>2017-12-05 02:32:53 +0100
commitbc8f91665b3f2fd94b80217e433dc90383e75ae4 (patch)
tree801a19c305b6d0ea10904a9d680cd5ab0d7b623c /drivers/scsi/3w-sas.c
parentscsi: 3ware: fix 32-bit time calculations (diff)
downloadlinux-bc8f91665b3f2fd94b80217e433dc90383e75ae4.tar.xz
linux-bc8f91665b3f2fd94b80217e433dc90383e75ae4.zip
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-sas.c')
-rw-r--r--drivers/scsi/3w-sas.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index c283fdb3cb24..cf9f2a09b47d 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -407,11 +407,10 @@ out:
static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
{
u32 schedulertime;
- struct timeval utc;
TW_Command_Full *full_command_packet;
TW_Command *command_packet;
TW_Param_Apache *param;
- u32 local_time;
+ time64_t local_time;
/* Fill out the command packet */
full_command_packet = tw_dev->command_packet_virt[request_id];
@@ -433,10 +432,9 @@ static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
/* Convert system time in UTC to local time seconds since last
Sunday 12:00AM */
- do_gettimeofday(&utc);
- local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
- schedulertime = local_time - (3 * 86400);
- schedulertime = cpu_to_le32(schedulertime % 604800);
+ local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60));
+ div_u64_rem(local_time - (3 * 86400), 604800, &schedulertime);
+ schedulertime = cpu_to_le32(schedulertime);
memcpy(param->data, &schedulertime, sizeof(u32));