rtc: sun6i: Fix time overflow handling
authorAndre Przywara <andre.przywara@arm.com>
Fri, 11 Feb 2022 12:26:28 +0000 (12:26 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 May 2022 07:58:59 +0000 (09:58 +0200)
commitc06a99a6605f524ff5ef096646e9501fc905366e
treeb7e5a2b44aba4ccee629fb22111e56c7145d8a7a
parente0b1473f8d87abaa25ac7528cfd6eba28821aeb1
rtc: sun6i: Fix time overflow handling

[ Upstream commit 9f6cd82eca7e91a0d0311242a87c6aa3c2737968 ]

Using "unsigned long" for UNIX timestamps is never a good idea, and
comparing the value of such a variable against U32_MAX does not do
anything useful on 32-bit systems.

Use the proper time64_t type when dealing with timestamps, and avoid
cutting down the time range unnecessarily. This also fixes the flawed
check for the alarm time being too far into the future.

The check for this condition is actually somewhat theoretical, as the
RTC counts till 2033 only anyways, and 2^32 seconds from now is not
before the year 2157 - at which point I hope nobody will be using this
hardware anymore.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220211122643.1343315-4-andre.przywara@arm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-sun6i.c