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

rtc: Introduce rtc_tm_sub() helper function

There're many sites need comparing the two rtc_time variants for many
rtc drivers, especially in the instances of rtc_class_ops::set_alarm().

So add this common helper function to make things easy.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
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
92000257 626fea04

+8
+8
include/linux/rtc.h
··· 24 24 ktime_t rtc_tm_to_ktime(struct rtc_time tm); 25 25 struct rtc_time rtc_ktime_to_tm(ktime_t kt); 26 26 27 + /* 28 + * rtc_tm_sub - Return the difference in seconds. 29 + */ 30 + static inline time64_t rtc_tm_sub(struct rtc_time *lhs, struct rtc_time *rhs) 31 + { 32 + return rtc_tm_to_time64(lhs) - rtc_tm_to_time64(rhs); 33 + } 34 + 27 35 /** 28 36 * Deprecated. Use rtc_time64_to_tm(). 29 37 */