]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - arch/m68k/mac/misc.c
m68k: mac: Use time64_t in RTC handling
authorArnd Bergmann <arnd@arndb.de>
Tue, 19 Jun 2018 14:02:28 +0000 (16:02 +0200)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Sun, 29 Jul 2018 08:44:58 +0000 (10:44 +0200)
commit5b9bfb8ec467b2017f36d7675434822271ce3d29
treebadd1ef812f661c2ca4801b79e35d936a79ff9fe
parent9eb8be602bf8d550a33b4e1f9fac543bd5c89f4d
m68k: mac: Use time64_t in RTC handling

The real-time clock on m68k (and powerpc) mac systems uses an unsigned
32-bit value starting in 1904, which overflows in 2040, about two years
later than everyone else, but this gets wrapped around in the Linux
code in 2038 already because of the deprecated usage of time_t and/or
long in the conversion.

Getting rid of the deprecated interfaces makes it work until 2040 as
documented, and it could be easily extended by reinterpreting
the resulting time64_t as a positive number. For the moment, I'm
adding a WARN_ON() that triggers if we encounter a time before 1970
or after 2040 (the two are indistinguishable).

This brings it in line with the corresponding code that we have on
powerpc macintosh.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[fthain: Adopt __u32 for the union in via_read_time(), consistent with
 changes to via_write_time()]
[fthain: Use lower_32_bits() in via_write_time(), consistent with changes
 to pmu_write_time() and cuda_write_time()]
[fthain: Have via_read_time() return a time64_t, consistent with changes
 to pmu_read_time() and cuda_read_time()]
[fthain: Drop the pointless wraparound conditional in via_read_time()]
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
[geert: Drop WARN_ON(), as it is reported to trigger on powermac]
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
arch/m68k/mac/misc.c