From c2c11ae4b6bc03b41720337028b940cbec9e316f Mon Sep 17 00:00:00 2001 From: "pang.xunlei" Date: Tue, 18 Nov 2014 19:15:19 +0800 Subject: rtc/lib: Provide y2038 safe rtc_tm_to_time()/rtc_time_to_tm() replacement As part of addressing "y2038 problem" for in-kernel uses, this patch adds safe rtc_tm_to_time64()/rtc_time64_to_tm() respectively using time64_t. After this patch, rtc_tm_to_time() is deprecated and all its call sites will be fixed using corresponding safe versions, it can be removed when having no users. Also change rtc_tm_to_time64() to return time64_t directly instead of just as a parameter like rtc_tm_to_time() does. After this patch, rtc_time_to_tm() is deprecated and all its call sites will be fixed using corresponding safe versions, it can be removed when having no users. In addition, change rtc_tm_to_ktime() and rtc_ktime_to_tm() to use the safe version in passing. Signed-off-by: pang.xunlei Signed-off-by: John Stultz --- include/linux/rtc.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'include/linux/rtc.h') diff --git a/include/linux/rtc.h b/include/linux/rtc.h index c2c28975293c..6d6be09a2fe5 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -19,11 +19,28 @@ extern int rtc_month_days(unsigned int month, unsigned int year); extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); extern int rtc_valid_tm(struct rtc_time *tm); -extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); -extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); +extern time64_t rtc_tm_to_time64(struct rtc_time *tm); +extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm); ktime_t rtc_tm_to_ktime(struct rtc_time tm); struct rtc_time rtc_ktime_to_tm(ktime_t kt); +/** + * Deprecated. Use rtc_time64_to_tm(). + */ +static inline void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) +{ + rtc_time64_to_tm(time, tm); +} + +/** + * Deprecated. Use rtc_tm_to_time64(). + */ +static inline int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) +{ + *time = rtc_tm_to_time64(tm); + + return 0; +} #include #include -- cgit v1.2.3