mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
rtc: ftrtc010: fix cast
The hour and minute registers will rollover before the multiplication to convert to a number of seconds can exceed an 32bit integer, there is no need to cast them. Reported-by: Dan Carpenter <error27@gmail.com> Link: https://patch.msgid.link/20261002105946.8rdteIpO7uWGEcTlS65F8iSi4gsRoXi2kgq8FTSaDPA@z/ Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20261005111502.159855-1-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
32f04694fa
commit
b8f98c67b3
|
|
@ -72,7 +72,7 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|||
days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS);
|
||||
offset = readl(rtc->rtc_base + FTRTC010_RTC_RECORD);
|
||||
|
||||
time = (timeu64_t)(offset + days * 86400 + hour * 3600 + min * 60 + sec);
|
||||
time = offset + (timeu64_t)days * 86400 + hour * 3600 + min * 60 + sec;
|
||||
|
||||
rtc_time64_to_tm(time, tm);
|
||||
|
||||
|
|
@ -92,8 +92,7 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|||
hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR);
|
||||
day = readl(rtc->rtc_base + FTRTC010_RTC_DAYS);
|
||||
|
||||
offset = time - ((timeu64_t)day * 86400 + (timeu64_t)hour * 3600 +
|
||||
(timeu64_t)min * 60 + (timeu64_t)sec);
|
||||
offset = time - ((timeu64_t)day * 86400 + hour * 3600 + min * 60 + sec);
|
||||
|
||||
writel(offset, rtc->rtc_base + FTRTC010_RTC_RECORD);
|
||||
writel(0x01, rtc->rtc_base + FTRTC010_RTC_CR);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user