aboutsummaryrefslogtreecommitdiff
path: root/include/rtc.h
diff options
context:
space:
mode:
authorJan Kiszka2022-04-24 11:34:56 +0200
committerTom Rini2022-05-05 15:06:02 -0400
commit90c52423be9933d5e85c20c6a0266b2c565f030a (patch)
tree3ad08a48bba967f6e894417e84e5754ec5dacebf /include/rtc.h
parentbfae2744dd136198a97b480bc0cc1814663fe33b (diff)
lib/date: Make rtc_mktime and mktime64 Y2038-ready
We currently overflow due to wrong types used internally in rtc_mktime, on all platforms, and we return a too small type on 32-bit. One consumer that directly benefits from this is mktime64. Many others may still store the result in a wrong type. While at it, drop the redundant cast of mon in rtc_mktime (obsoleted by 714209832db1). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Diffstat (limited to 'include/rtc.h')
-rw-r--r--include/rtc.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/rtc.h b/include/rtc.h
index 6c7fcadd488..10104e3bf5a 100644
--- a/include/rtc.h
+++ b/include/rtc.h
@@ -16,6 +16,8 @@
#include <bcd.h>
#include <rtc_def.h>
+typedef int64_t time64_t;
+
#ifdef CONFIG_DM_RTC
struct udevice;
@@ -301,7 +303,7 @@ int rtc_calc_weekday(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
+ * rtc_mktime() - Convert a broken-out time into a time64_t value
*
* The following fields need to be valid for this function to work:
* tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year
@@ -309,9 +311,9 @@ void rtc_to_tm(u64 time_t, struct rtc_time *time);
* Note that tm_wday and tm_yday are ignored.
*
* @time: Broken-out time to convert
- * Return: corresponding time_t value, seconds since 1970-01-01 00:00:00
+ * Return: corresponding time64_t value, seconds since 1970-01-01 00:00:00
*/
-unsigned long rtc_mktime(const struct rtc_time *time);
+time64_t rtc_mktime(const struct rtc_time *time);
/**
* rtc_month_days() - The number of days in the month