summaryrefslogtreecommitdiff
path: root/include/rtc.h
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-07-08 00:39:11 +0300
committerTom Rini <trini@konsulko.com>2018-07-20 00:03:36 +0300
commit992c1db45591b891935a6da5c3f14d8af5def05b (patch)
tree17a27182e132e737035202d4514905d6255a1ffe /include/rtc.h
parent0938cff73727f562cd49c55e1d47d09bbffd4915 (diff)
downloadu-boot-992c1db45591b891935a6da5c3f14d8af5def05b.tar.xz
drivers: rtc: resolve year 2038 problem in rtc_to_tm
Our implementation of rtc_to_tm() cannot handle dates of more than 0x7fffffff seconds after 1970-01-01. Adopt the Linux kernel implementation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'include/rtc.h')
-rw-r--r--include/rtc.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/rtc.h b/include/rtc.h
index 746624d799..0d964d56d5 100644
--- a/include/rtc.h
+++ b/include/rtc.h
@@ -208,7 +208,18 @@ void rtc_write32(int reg, u32 value);
* rtc_init() - Set up the real time clock ready for use
*/
void rtc_init(void);
-#endif
+#endif /* CONFIG_DM_RTC */
+
+/**
+ * is_leap_year - Check if year is a leap year
+ *
+ * @year Year
+ * @return 1 if leap year
+ */
+static inline bool is_leap_year(unsigned int year)
+{
+ return (!(year % 4) && (year % 100)) || !(year % 400);
+}
/**
* rtc_calc_weekday() - Work out the weekday from a time
@@ -231,9 +242,8 @@ int rtc_calc_weekday(struct rtc_time *time);
*
* @time_t: Number of seconds since 1970-01-01 00:00:00
* @time: Place to put the broken-out time
- * @return 0 if OK, -EINVAL if the weekday could not be determined
*/
-int rtc_to_tm(int time_t, struct rtc_time *time);
+void rtc_to_tm(u64 time_t, struct rtc_time *time);
/**
* rtc_mktime() - Convert a broken-out time into a time_t value