From 9f9276c34cbbf67fd1b3788f0be326b47fc69123 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Apr 2015 12:37:18 -0600 Subject: dm: rtc: Rename to_tm() to rtc_to_tm() and add error code Rename this function so that it is clear that it is provided by the RTC. Also return an error when it cannot function as expected. This is unlikely to occur since it works for dates since 1752 and many RTCs do not support such old dates. Still it is better to be accurate. Signed-off-by: Simon Glass Acked-by: Heiko Schocher --- drivers/rtc/date.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/rtc/date.c') diff --git a/drivers/rtc/date.c b/drivers/rtc/date.c index 2000565736..79beb940e5 100644 --- a/drivers/rtc/date.c +++ b/drivers/rtc/date.c @@ -71,7 +71,7 @@ int rtc_calc_weekday(struct rtc_time *tm) return 0; } -void to_tm(int tim, struct rtc_time * tm) +int rtc_to_tm(int tim, struct rtc_time *tm) { register int i; register long hms, day; @@ -103,10 +103,14 @@ void to_tm(int tim, struct rtc_time * tm) /* Days are what is left over (+1) from all that. */ tm->tm_mday = day + 1; + /* Zero unused fields */ + tm->tm_yday = 0; + tm->tm_isdst = 0; + /* * Determine the day of week */ - rtc_calc_weekday(tm); + return rtc_calc_weekday(tm); } /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. -- cgit v1.2.1