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

rtc: mt6397: fix build on some 32bits platforms

On some !ARM 32bits platforms, the following compilation error happens
because of the division on a 64bits value in mtk_rtc_read_time():

drivers/built-in.o: In function `mtk_rtc_read_time':
rtc-mt6397.c:(.text+0x265d13f): undefined reference to `__divdi3'
rtc-mt6397.c:(.text+0x265d150): undefined reference to `__moddi3'

Use div_s64() as done in rtc_time64_to_tm() to solve that.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Acked-by: Eddie Huang <eddie.huang@mediatek.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

+3 -2
+3 -2
drivers/rtc/rtc-mt6397.c
··· 150 150 { 151 151 time64_t time; 152 152 struct mt6397_rtc *rtc = dev_get_drvdata(dev); 153 - int sec, ret; 153 + int days, sec, ret; 154 154 155 155 do { 156 156 ret = __mtk_rtc_read_time(rtc, tm, &sec); ··· 171 171 /* rtc_tm_to_time64 covert Gregorian date to seconds since 172 172 * 01-01-1970 00:00:00, and this date is Thursday. 173 173 */ 174 - tm->tm_wday = (time / 86400 + 4) % 7; 174 + days = div_s64(time, 86400); 175 + tm->tm_wday = (days + 4) % 7; 175 176 176 177 exit: 177 178 return ret;