]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.28/scsi-smartpqi-fix-time-handling.patch
Remove duplicated commits
[thirdparty/kernel/stable-queue.git] / releases / 4.9.28 / scsi-smartpqi-fix-time-handling.patch
CommitLineData
b74db2ac
GKH
1From ed10858eadd4988260c6bc7d75fc25176342b5a7 Mon Sep 17 00:00:00 2001
2From: Arnd Bergmann <arnd@arndb.de>
3Date: Fri, 17 Feb 2017 16:03:52 +0100
4Subject: scsi: smartpqi: fix time handling
5
6From: Arnd Bergmann <arnd@arndb.de>
7
8commit ed10858eadd4988260c6bc7d75fc25176342b5a7 upstream.
9
10When we have turned off RTC support, the smartpqi driver fails to build:
11
12ERROR: "rtc_time64_to_tm" [drivers/scsi/smartpqi/smartpqi.ko] undefined!
13
14This is easily avoided by using the generic 'struct tm' based helper rather
15than the RTC specific one. While fixing this, I noticed that even though
16the driver uses time64_t for storing seconds, it gets them from the
17old 32-bit struct timeval. To address this, we can simplify the code
18by calling ktime_get_real_seconds() directly.
19
20Fixes: 6c223761eb54 ("smartpqi: initial commit of Microsemi smartpqi driver")
21Signed-off-by: Arnd Bergmann <arnd@arndb.de>
22Acked-by: Don Brace <don.brace@microsemi.com>
23Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
24Signed-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);