diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-02-17 10:03:52 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-14 08:00:20 -0400 |
commit | 2d652d0abd3ccda1097345d13d728b8ba1b7c68f (patch) | |
tree | 29ab6c06cb208cb5f9dc3d97bdadd4fa87cd8a49 | |
parent | a46d03e3517990375bc4aafe7df969309245f068 (diff) |
scsi: smartpqi: fix time handling
commit ed10858eadd4988260c6bc7d75fc25176342b5a7 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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/scsi/smartpqi/smartpqi_init.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index a535b2661f38..96a343ec8313 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c | |||
@@ -533,8 +533,7 @@ static int pqi_write_current_time_to_host_wellness( | |||
533 | size_t buffer_length; | 533 | size_t buffer_length; |
534 | time64_t local_time; | 534 | time64_t local_time; |
535 | unsigned int year; | 535 | unsigned int year; |
536 | struct timeval time; | 536 | struct tm tm; |
537 | struct rtc_time tm; | ||
538 | 537 | ||
539 | buffer_length = sizeof(*buffer); | 538 | buffer_length = sizeof(*buffer); |
540 | 539 | ||
@@ -551,9 +550,8 @@ static int pqi_write_current_time_to_host_wellness( | |||
551 | put_unaligned_le16(sizeof(buffer->time), | 550 | put_unaligned_le16(sizeof(buffer->time), |
552 | &buffer->time_length); | 551 | &buffer->time_length); |
553 | 552 | ||
554 | do_gettimeofday(&time); | 553 | local_time = ktime_get_real_seconds(); |
555 | local_time = time.tv_sec - (sys_tz.tz_minuteswest * 60); | 554 | time64_to_tm(local_time, -sys_tz.tz_minuteswest * 60, &tm); |
556 | rtc_time64_to_tm(local_time, &tm); | ||
557 | year = tm.tm_year + 1900; | 555 | year = tm.tm_year + 1900; |
558 | 556 | ||
559 | buffer->time[0] = bin2bcd(tm.tm_hour); | 557 | buffer->time[0] = bin2bcd(tm.tm_hour); |