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

rtc: isl1208: Replace deprecated rtc_tm_to_time()

isl1208_i2c_set_alarm() uses deprecated rtc_tm_to_time(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
- Replacing rtc_tm_to_time() with rtc_tm_sub()

Cc: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Xunlei Pang and committed by
Alexandre Belloni
f118db1e 92000257

+1 -8
+1 -8
drivers/rtc/rtc-isl1208.c
··· 370 370 struct rtc_time *alarm_tm = &alarm->time; 371 371 u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, }; 372 372 const int offs = ISL1208_REG_SCA; 373 - unsigned long rtc_secs, alarm_secs; 374 373 struct rtc_time rtc_tm; 375 374 int err, enable; 376 375 377 376 err = isl1208_i2c_read_time(client, &rtc_tm); 378 377 if (err) 379 378 return err; 380 - err = rtc_tm_to_time(&rtc_tm, &rtc_secs); 381 - if (err) 382 - return err; 383 - err = rtc_tm_to_time(alarm_tm, &alarm_secs); 384 - if (err) 385 - return err; 386 379 387 380 /* If the alarm time is before the current time disable the alarm */ 388 - if (!alarm->enabled || alarm_secs <= rtc_secs) 381 + if (!alarm->enabled || rtc_tm_sub(alarm_tm, &rtc_tm) <= 0) 389 382 enable = 0x00; 390 383 else 391 384 enable = 0x80;