aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/common/rtctime.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c
index 48b1e19b131f..e851d86c212c 100644
--- a/arch/arm/common/rtctime.c
+++ b/arch/arm/common/rtctime.c
@@ -128,19 +128,27 @@ EXPORT_SYMBOL(rtc_tm_to_time);
128/* 128/*
129 * Calculate the next alarm time given the requested alarm time mask 129 * Calculate the next alarm time given the requested alarm time mask
130 * and the current time. 130 * and the current time.
131 *
132 * FIXME: for now, we just copy the alarm time because we're lazy (and
133 * is therefore buggy - setting a 10am alarm at 8pm will not result in
134 * the alarm triggering.)
135 */ 131 */
136void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm) 132void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm)
137{ 133{
134 unsigned long next_time;
135 unsigned long now_time;
136
138 next->tm_year = now->tm_year; 137 next->tm_year = now->tm_year;
139 next->tm_mon = now->tm_mon; 138 next->tm_mon = now->tm_mon;
140 next->tm_mday = now->tm_mday; 139 next->tm_mday = now->tm_mday;
141 next->tm_hour = alrm->tm_hour; 140 next->tm_hour = alrm->tm_hour;
142 next->tm_min = alrm->tm_min; 141 next->tm_min = alrm->tm_min;
143 next->tm_sec = alrm->tm_sec; 142 next->tm_sec = alrm->tm_sec;
143
144 rtc_tm_to_time(now, &now_time);
145 rtc_tm_to_time(next, &next_time);
146
147 if (next_time < now_time) {
148 /* Advance one day */
149 next_time += 60 * 60 * 24;
150 rtc_time_to_tm(next_time, next);
151 }
144} 152}
145 153
146static inline int rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm) 154static inline int rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm)