Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: interface: use timeu64_t for range_max

For rtc drivers where rtc->range_max is set U64_MAX, like the PS3 rtc,
rtc_valid_range() always returns -ERANGE. This is because the local
variable range_max has type time64_t, so the test
if (time < range_min || time > range_max)
return -ERANGE;
becomes (time < range_min || time > -1), which always evaluates to true.
timeu64_t should be used, since it's the type of rtc->range_max.

Signed-off-by: Emmanuel Nicolet <emmanuel.nicolet@gmail.com>
Link: https://lore.kernel.org/r/20190927110446.GA6289@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Emmanuel Nicolet and committed by
Alexandre Belloni
eaa6ef56 288d9cf1

+1 -1
+1 -1
drivers/rtc/interface.c
··· 70 70 time64_t time = rtc_tm_to_time64(tm); 71 71 time64_t range_min = rtc->set_start_time ? rtc->start_secs : 72 72 rtc->range_min; 73 - time64_t range_max = rtc->set_start_time ? 73 + timeu64_t range_max = rtc->set_start_time ? 74 74 (rtc->start_secs + rtc->range_max - rtc->range_min) : 75 75 rtc->range_max; 76 76