linux_dsm_epyc7002/arch/powerpc/platforms/powermac
Arnd Bergmann 22db552b50 powerpc/powermac: Fix rtc read/write functions
As Mathieu pointed out, my conversion to time64_t was incorrect and
resulted in negative times to be read from the RTC. The problem is
that during the conversion from a byte array to a time64_t, the
'unsigned char' variable holding the top byte gets turned into a
negative signed 32-bit integer before being assigned to the 64-bit
variable for any times after 1972.

This changes the logic to cast to an unsigned 32-bit number first for
the Macintosh time and then convert that to the Unix time, which then
gives us a time in the documented 1904..2040 year range. I decided not
to use the longer 1970..2106 range that other drivers use, for
consistency with the literal interpretation of the register, but that
could be easily changed if we decide we want to support any Mac after
2040.

Just to be on the safe side, I'm also adding a WARN_ON that will
trigger if either the year 2040 has come and is observed by this
driver, or we run into an RTC that got set back to a pre-1970 date for
some reason (the two are indistinguishable).

For the RTC write functions, Andreas found another problem: both
pmu_request() and cuda_request() are varargs functions, so changing
the type of the arguments passed into them from 32 bit to 64 bit
breaks the API for the set_rtc_time functions. This changes it back to
32 bits.

The same code exists in arch/m68k/ and is patched in an identical way
now in a separate patch.

Fixes: 5bfd643583 ("powerpc: use time64_t in read_persistent_clock")
Reported-by: Mathieu Malaterre <malat@debian.org>
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-06-27 13:48:49 +10:00
..
backlight.c powerpc: Fix old-style function definition 2018-01-21 23:37:44 +11:00
bootx_init.c powerpc: fix spelling mistake: "Usupported" -> "Unsupported" 2018-06-05 11:33:43 +10:00
cache.S powerpc: Fix misspellings in comments. 2016-03-01 19:27:20 +11:00
feature.c pci-v4.16-changes 2018-02-06 09:59:40 -08:00
Kconfig License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
low_i2c.c powerpc: Use sizeof(*foo) rather than sizeof(struct foo) 2018-03-20 16:47:53 +11:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nvram.c powerpc: Remove more traces of bootmem 2014-11-19 21:41:51 +11:00
pci.c powerpc/sparse: Fix plain integer as NULL pointer warning 2018-05-25 12:04:38 +10:00
pfunc_base.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pfunc_core.c powerpc: Use sizeof(*foo) rather than sizeof(struct foo) 2018-03-20 16:47:53 +11:00
pic.c powerpc: make use of for_each_node_by_type() instead of open-coding it 2018-01-16 23:47:10 +11:00
pmac.h powerpc: use time64_t in read_persistent_clock 2018-06-03 20:43:33 +10:00
setup.c powerpc/powermac: Add missing prototype for note_bootable_part() 2018-05-25 12:04:42 +10:00
sleep.S powerpc/mm: Introduce MMU features 2008-12-21 14:21:16 +11:00
smp.c powerpc/powermac: Move pmac_pfunc_base_install prototype to header file 2018-05-25 12:04:41 +10:00
time.c powerpc/powermac: Fix rtc read/write functions 2018-06-27 13:48:49 +10:00
udbg_adb.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
udbg_scc.c of: add 'of_' prefix to machine_is_compatible() 2010-02-09 08:33:00 -07:00