On Thursday 05 November 2015 12:21:13 Alison Schofield wrote:
Replace the use of struct timeval and do_gettimeofday() with 64 bit ktime_get_real_seconds. Prevents 32-bit type overflow in year 2038 on 32-bit systems.
Driver was using the seconds portion of struct timeval (.tv_secs) to pass a millseconds timestamp to the firmware. This change maintains that same behavior using ktime_get_real_seconds.
The structure used to pass the timestamp to firmware is 48 bits and works fine as long as the top 16 bits are zero and they will be zero for a long time..ie. thousands of years.
Signed-off-by: Alison Schofield amsfield22@gmail.com
Very good. Please go on and post this to the maintainers now.
Changes in v2:
- add pmcraid to subject line
- update commit msg w additional detail
- add alternative change proposal per reviewer feedback
Alternative Change: Add sub second granularity to timestamp
As noted above, the driver only used the seconds portion of timeval, ignores the microseconds portion, and by multiplying by 1000 effectively does a <<10 and always writes zero into timestamp[0].
The alternative change would pass all the bits to the firmware:
struct timespec64 ts; ktime_get_real_ts64(&ts); timestamp = ts.tv_sec * MSEC_PER_SEC + ts.tv_nsec / NSEC_PER_MSEC;
I guess this text could be part of the patch description above the '---' line, to keep it in the git history if anyone cares about this later.
Arnd