Skip to contentSkip to conversation

rtc: use timeu64_t for range_max

PATCH Applied Emmanuel Nicolet 2 participants 2 messages Sep 27, 2019 – Oct 3, 2019 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: use timeu64_t for range_max

Hi,
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.

---
 drivers/rtc/interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/interface.c +1 -1
index c93ef33b01d3..eea700723976 100644
@@ -70,7 +70,7 @@ static int rtc_valid_range(struct rtc_device *rtc, struct rtc_time *tm)
 		time64_t time = rtc_tm_to_time64(tm);
 		time64_t range_min = rtc->set_start_time ? rtc->start_secs :
 			rtc->range_min;
-		time64_t range_max = rtc->set_start_time ?
+		timeu64_t range_max = rtc->set_start_time ?
 			(rtc->start_secs + rtc->range_max - rtc->range_min) :
 			rtc->range_max;
 
Signature · 1 line
2.23.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Emmanuel Nicolet

Hi,
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;
Quoted 8 lines

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.

---
 drivers/rtc/interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com