]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: smartpqi: fix time handling
authorArnd Bergmann <arnd@arndb.de>
Fri, 17 Feb 2017 15:03:52 +0000 (16:03 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 22 Feb 2017 23:41:42 +0000 (18:41 -0500)
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: 6c223761eb54 ("smartpqi: initial commit of Microsemi smartpqi driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/smartpqi/smartpqi_init.c

index 11c0dfb3dfa392a025c6ef29c1977247ee46cfc5..657ad15682a34cb01a3ccee14e2676e0a706bc93 100644 (file)
@@ -534,8 +534,7 @@ static int pqi_write_current_time_to_host_wellness(
        size_t buffer_length;
        time64_t local_time;
        unsigned int year;
-       struct timeval time;
-       struct rtc_time tm;
+       struct tm tm;
 
        buffer_length = sizeof(*buffer);
 
@@ -552,9 +551,8 @@ static int pqi_write_current_time_to_host_wellness(
        put_unaligned_le16(sizeof(buffer->time),
                &buffer->time_length);
 
-       do_gettimeofday(&time);
-       local_time = time.tv_sec - (sys_tz.tz_minuteswest * 60);
-       rtc_time64_to_tm(local_time, &tm);
+       local_time = ktime_get_real_seconds();
+       time64_to_tm(local_time, -sys_tz.tz_minuteswest * 60, &tm);
        year = tm.tm_year + 1900;
 
        buffer->time[0] = bin2bcd(tm.tm_hour);