summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/lib.c')
-rw-r--r--drivers/rtc/lib.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/rtc/lib.c b/drivers/rtc/lib.c
index 3d0dc70ff7d8..e36c233455ee 100644
--- a/drivers/rtc/lib.c
+++ b/drivers/rtc/lib.c
@@ -22,7 +22,7 @@ static const unsigned short rtc_ydays[2][13] = {
22 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } 22 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
23}; 23};
24 24
25#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400) 25#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
26 26
27/* 27/*
28 * The number of days in the month. 28 * The number of days in the month.
@@ -38,11 +38,10 @@ EXPORT_SYMBOL(rtc_month_days);
38 */ 38 */
39int rtc_year_days(unsigned int day, unsigned int month, unsigned int year) 39int rtc_year_days(unsigned int day, unsigned int month, unsigned int year)
40{ 40{
41 return rtc_ydays[is_leap_year(year)][month] + day-1; 41 return rtc_ydays[is_leap_year(year)][month] + day - 1;
42} 42}
43EXPORT_SYMBOL(rtc_year_days); 43EXPORT_SYMBOL(rtc_year_days);
44 44
45
46/* 45/*
47 * rtc_time64_to_tm - Converts time64_t to rtc_time. 46 * rtc_time64_to_tm - Converts time64_t to rtc_time.
48 * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. 47 * Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
@@ -94,13 +93,14 @@ EXPORT_SYMBOL(rtc_time64_to_tm);
94 */ 93 */
95int rtc_valid_tm(struct rtc_time *tm) 94int rtc_valid_tm(struct rtc_time *tm)
96{ 95{
97 if (tm->tm_year < 70 96 if (tm->tm_year < 70 ||
98 || ((unsigned)tm->tm_mon) >= 12 97 ((unsigned int)tm->tm_mon) >= 12 ||
99 || tm->tm_mday < 1 98 tm->tm_mday < 1 ||
100 || tm->tm_mday > rtc_month_days(tm->tm_mon, ((unsigned)tm->tm_year + 1900)) 99 tm->tm_mday > rtc_month_days(tm->tm_mon,
101 || ((unsigned)tm->tm_hour) >= 24 100 ((unsigned int)tm->tm_year + 1900)) ||
102 || ((unsigned)tm->tm_min) >= 60 101 ((unsigned int)tm->tm_hour) >= 24 ||
103 || ((unsigned)tm->tm_sec) >= 60) 102 ((unsigned int)tm->tm_min) >= 60 ||
103 ((unsigned int)tm->tm_sec) >= 60)
104 return -EINVAL; 104 return -EINVAL;
105 105
106 return 0; 106 return 0;
@@ -113,7 +113,7 @@ EXPORT_SYMBOL(rtc_valid_tm);
113 */ 113 */
114time64_t rtc_tm_to_time64(struct rtc_time *tm) 114time64_t rtc_tm_to_time64(struct rtc_time *tm)
115{ 115{
116 return mktime64(((unsigned)tm->tm_year + 1900), tm->tm_mon + 1, 116 return mktime64(((unsigned int)tm->tm_year + 1900), tm->tm_mon + 1,
117 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); 117 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
118} 118}
119EXPORT_SYMBOL(rtc_tm_to_time64); 119EXPORT_SYMBOL(rtc_tm_to_time64);