Commit 2d652d0a authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

scsi: smartpqi: fix time handling

commit ed10858e upstream.

When we have turned off RTC support, the smartpqi driver fails to build:

ERROR: "rtc_time64_to_tm" [drivers/scsi/smartpqi/smartpqi.ko] undefined!

This is easily avoided by using the generic 'struct tm' based helper rather
than the RTC specific one. While fixing this, I noticed that even though
the driver uses time64_t for storing seconds, it gets them from the
old 32-bit struct timeval. To address this, we can simplify the code
by calling ktime_get_real_seconds() directly.

Fixes: 6c223761 ("smartpqi: initial commit of Microsemi smartpqi driver")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarDon Brace <don.brace@microsemi.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a46d03e3
...@@ -533,8 +533,7 @@ static int pqi_write_current_time_to_host_wellness( ...@@ -533,8 +533,7 @@ static int pqi_write_current_time_to_host_wellness(
size_t buffer_length; size_t buffer_length;
time64_t local_time; time64_t local_time;
unsigned int year; unsigned int year;
struct timeval time; struct tm tm;
struct rtc_time tm;
buffer_length = sizeof(*buffer); buffer_length = sizeof(*buffer);
...@@ -551,9 +550,8 @@ static int pqi_write_current_time_to_host_wellness( ...@@ -551,9 +550,8 @@ static int pqi_write_current_time_to_host_wellness(
put_unaligned_le16(sizeof(buffer->time), put_unaligned_le16(sizeof(buffer->time),
&buffer->time_length); &buffer->time_length);
do_gettimeofday(&time); local_time = ktime_get_real_seconds();
local_time = time.tv_sec - (sys_tz.tz_minuteswest * 60); time64_to_tm(local_time, -sys_tz.tz_minuteswest * 60, &tm);
rtc_time64_to_tm(local_time, &tm);
year = tm.tm_year + 1900; year = tm.tm_year + 1900;
buffer->time[0] = bin2bcd(tm.tm_hour); buffer->time[0] = bin2bcd(tm.tm_hour);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment