]>
Commit | Line | Data |
---|---|---|
b74db2ac GKH |
1 | From ed10858eadd4988260c6bc7d75fc25176342b5a7 Mon Sep 17 00:00:00 2001 |
2 | From: Arnd Bergmann <arnd@arndb.de> | |
3 | Date: Fri, 17 Feb 2017 16:03:52 +0100 | |
4 | Subject: scsi: smartpqi: fix time handling | |
5 | ||
6 | From: Arnd Bergmann <arnd@arndb.de> | |
7 | ||
8 | commit ed10858eadd4988260c6bc7d75fc25176342b5a7 upstream. | |
9 | ||
10 | When we have turned off RTC support, the smartpqi driver fails to build: | |
11 | ||
12 | ERROR: "rtc_time64_to_tm" [drivers/scsi/smartpqi/smartpqi.ko] undefined! | |
13 | ||
14 | This is easily avoided by using the generic 'struct tm' based helper rather | |
15 | than the RTC specific one. While fixing this, I noticed that even though | |
16 | the driver uses time64_t for storing seconds, it gets them from the | |
17 | old 32-bit struct timeval. To address this, we can simplify the code | |
18 | by calling ktime_get_real_seconds() directly. | |
19 | ||
20 | Fixes: 6c223761eb54 ("smartpqi: initial commit of Microsemi smartpqi driver") | |
21 | Signed-off-by: Arnd Bergmann <arnd@arndb.de> | |
22 | Acked-by: Don Brace <don.brace@microsemi.com> | |
23 | Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> | |
24 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
25 | ||
26 | --- | |
27 | drivers/scsi/smartpqi/smartpqi_init.c | 8 +++----- | |
28 | 1 file changed, 3 insertions(+), 5 deletions(-) | |
29 | ||
30 | --- a/drivers/scsi/smartpqi/smartpqi_init.c | |
31 | +++ b/drivers/scsi/smartpqi/smartpqi_init.c | |
32 | @@ -533,8 +533,7 @@ static int pqi_write_current_time_to_hos | |
33 | size_t buffer_length; | |
34 | time64_t local_time; | |
35 | unsigned int year; | |
36 | - struct timeval time; | |
37 | - struct rtc_time tm; | |
38 | + struct tm tm; | |
39 | ||
40 | buffer_length = sizeof(*buffer); | |
41 | ||
42 | @@ -551,9 +550,8 @@ static int pqi_write_current_time_to_hos | |
43 | put_unaligned_le16(sizeof(buffer->time), | |
44 | &buffer->time_length); | |
45 | ||
46 | - do_gettimeofday(&time); | |
47 | - local_time = time.tv_sec - (sys_tz.tz_minuteswest * 60); | |
48 | - rtc_time64_to_tm(local_time, &tm); | |
49 | + local_time = ktime_get_real_seconds(); | |
50 | + time64_to_tm(local_time, -sys_tz.tz_minuteswest * 60, &tm); | |
51 | year = tm.tm_year + 1900; | |
52 | ||
53 | buffer->time[0] = bin2bcd(tm.tm_hour); |