linux/drivers/scsi/arcmsr
Arnd Bergmann 45596c7889 scsi: arcmsr: avoid do_gettimeofday
The arcmsr uses its own implementation of time_to_tm(), along with
do_gettimeofday() to read the current time. While the algorithm used
here is fine in principle, it suffers from two problems:

- it assigns the seconds portion of the timeval to a 32-bit unsigned
  integer that overflows in 2106 even on 64-bit architectures.

- do_gettimeofday() returns a time_t that overflows in 2038 on all
  32-bit systems.

This changes the time retrieval function to ktime_get_real_seconds(),
which returns a proper 64-bit value, and replaces the open-coded
time_to_tm() algorithm with a call to the safe time64_to_tm().

I checked way all numbers are indexed and found that months are given in
range 0..11 while the days are in range 1..31, same as 'struct tm', but
the year value that the firmware expects starts in 2000 while 'struct
tm' is based on year 1900, so it needs a small adjustment.

[mkp: checkpatch tweaks]

Fixes: b416c09947 ("scsi: arcmsr: Add a function to set date and time to firmware")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2018-01-22 20:04:02 -05:00
..
Makefile [SCSI] arcmsr: initial driver, version 1.20.00.13 2006-07-28 14:13:40 -05:00
arcmsr.h scsi: arcmsr: Update driver version to v1.40.00.04-20171130 2017-12-06 19:32:41 -05:00
arcmsr_attr.c arcmsr: add const to bin_attribute structures 2017-08-10 19:40:50 -04:00
arcmsr_hba.c scsi: arcmsr: avoid do_gettimeofday 2018-01-22 20:04:02 -05:00