Lines Matching full:alarm
179 struct rtc_wkalrm *alarm) in rtc_read_alarm_internal() argument
192 alarm->enabled = 0; in rtc_read_alarm_internal()
193 alarm->pending = 0; in rtc_read_alarm_internal()
194 alarm->time.tm_sec = -1; in rtc_read_alarm_internal()
195 alarm->time.tm_min = -1; in rtc_read_alarm_internal()
196 alarm->time.tm_hour = -1; in rtc_read_alarm_internal()
197 alarm->time.tm_mday = -1; in rtc_read_alarm_internal()
198 alarm->time.tm_mon = -1; in rtc_read_alarm_internal()
199 alarm->time.tm_year = -1; in rtc_read_alarm_internal()
200 alarm->time.tm_wday = -1; in rtc_read_alarm_internal()
201 alarm->time.tm_yday = -1; in rtc_read_alarm_internal()
202 alarm->time.tm_isdst = -1; in rtc_read_alarm_internal()
203 err = rtc->ops->read_alarm(rtc->dev.parent, alarm); in rtc_read_alarm_internal()
208 trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err); in rtc_read_alarm_internal()
212 int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in __rtc_read_alarm() argument
222 * creating invalid alarm->time values, for reasons like: in __rtc_read_alarm()
230 * to set up as e.g. "alarm 15 minutes after each hour". in __rtc_read_alarm()
235 * RTC driver prevents "periodic alarm" modes. in __rtc_read_alarm()
238 * may have wrapped in the interval since we read the RTC alarm, in __rtc_read_alarm()
242 * Reading the alarm and timestamp in the reverse sequence in __rtc_read_alarm()
246 * then read the RTC alarm value, in __rtc_read_alarm()
271 /* get the RTC alarm values, which may be incomplete */ in __rtc_read_alarm()
272 err = rtc_read_alarm_internal(rtc, alarm); in __rtc_read_alarm()
277 if (rtc_valid_tm(&alarm->time) == 0) { in __rtc_read_alarm()
278 rtc_add_offset(rtc, &alarm->time); in __rtc_read_alarm()
293 /* Fill in the missing alarm fields using the timestamp; we in __rtc_read_alarm()
294 * know there's at least one since alarm->time is invalid. in __rtc_read_alarm()
296 if (alarm->time.tm_sec == -1) in __rtc_read_alarm()
297 alarm->time.tm_sec = now.tm_sec; in __rtc_read_alarm()
298 if (alarm->time.tm_min == -1) in __rtc_read_alarm()
299 alarm->time.tm_min = now.tm_min; in __rtc_read_alarm()
300 if (alarm->time.tm_hour == -1) in __rtc_read_alarm()
301 alarm->time.tm_hour = now.tm_hour; in __rtc_read_alarm()
304 if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) { in __rtc_read_alarm()
305 alarm->time.tm_mday = now.tm_mday; in __rtc_read_alarm()
308 if ((unsigned int)alarm->time.tm_mon >= 12) { in __rtc_read_alarm()
309 alarm->time.tm_mon = now.tm_mon; in __rtc_read_alarm()
313 if (alarm->time.tm_year == -1) { in __rtc_read_alarm()
314 alarm->time.tm_year = now.tm_year; in __rtc_read_alarm()
319 /* Can't proceed if alarm is still invalid after replacing in __rtc_read_alarm()
322 err = rtc_valid_tm(&alarm->time); in __rtc_read_alarm()
328 t_alm = rtc_tm_to_time64(&alarm->time); in __rtc_read_alarm()
333 /* 24 hour rollover ... if it's now 10am Monday, an alarm that in __rtc_read_alarm()
339 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); in __rtc_read_alarm()
341 rtc_time64_to_tm(t_alm, &alarm->time); in __rtc_read_alarm()
344 /* Month rollover ... if it's the 31th, an alarm on the 3rd will in __rtc_read_alarm()
345 * be next month. An alarm matching on the 30th, 29th, or 28th in __rtc_read_alarm()
347 * this type of alarm. in __rtc_read_alarm()
350 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month"); in __rtc_read_alarm()
352 if (alarm->time.tm_mon < 11) { in __rtc_read_alarm()
353 alarm->time.tm_mon++; in __rtc_read_alarm()
355 alarm->time.tm_mon = 0; in __rtc_read_alarm()
356 alarm->time.tm_year++; in __rtc_read_alarm()
358 days = rtc_month_days(alarm->time.tm_mon, in __rtc_read_alarm()
359 alarm->time.tm_year); in __rtc_read_alarm()
360 } while (days < alarm->time.tm_mday); in __rtc_read_alarm()
365 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); in __rtc_read_alarm()
367 alarm->time.tm_year++; in __rtc_read_alarm()
368 } while (!is_leap_year(alarm->time.tm_year + 1900) && in __rtc_read_alarm()
369 rtc_valid_tm(&alarm->time) != 0); in __rtc_read_alarm()
373 dev_warn(&rtc->dev, "alarm rollover not handled\n"); in __rtc_read_alarm()
376 err = rtc_valid_tm(&alarm->time); in __rtc_read_alarm()
380 dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", in __rtc_read_alarm()
381 &alarm->time); in __rtc_read_alarm()
386 int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in rtc_read_alarm() argument
398 memset(alarm, 0, sizeof(struct rtc_wkalrm)); in rtc_read_alarm()
399 alarm->enabled = rtc->aie_timer.enabled; in rtc_read_alarm()
400 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); in rtc_read_alarm()
404 trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err); in rtc_read_alarm()
409 static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in __rtc_set_alarm() argument
415 err = rtc_valid_tm(&alarm->time); in __rtc_set_alarm()
419 scheduled = rtc_tm_to_time64(&alarm->time); in __rtc_set_alarm()
429 * XXX - We just checked to make sure the alarm time is not in __rtc_set_alarm()
431 * the is alarm set for the next second and the second ticks in __rtc_set_alarm()
432 * over right here, before we set the alarm. in __rtc_set_alarm()
435 rtc_subtract_offset(rtc, &alarm->time); in __rtc_set_alarm()
442 err = rtc->ops->set_alarm(rtc->dev.parent, alarm); in __rtc_set_alarm()
444 trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err); in __rtc_set_alarm()
448 int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in rtc_set_alarm() argument
457 err = rtc_valid_tm(&alarm->time); in rtc_set_alarm()
461 err = rtc_valid_range(rtc, &alarm->time); in rtc_set_alarm()
471 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); in rtc_set_alarm()
473 if (alarm->enabled) in rtc_set_alarm()
483 int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in rtc_initialize_alarm() argument
488 err = rtc_valid_tm(&alarm->time); in rtc_initialize_alarm()
500 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); in rtc_initialize_alarm()
503 /* Alarm has to be enabled & in the future for us to enqueue it */ in rtc_initialize_alarm()
504 if (alarm->enabled && (rtc_tm_to_ktime(now) < in rtc_initialize_alarm()
799 * the next alarm event appropriately.
825 struct rtc_wkalrm alarm; in rtc_timer_enqueue() local
828 alarm.time = rtc_ktime_to_tm(timer->node.expires); in rtc_timer_enqueue()
829 alarm.enabled = 1; in rtc_timer_enqueue()
830 err = __rtc_set_alarm(rtc, &alarm); in rtc_timer_enqueue()
859 * the next alarm event appropriately.
873 struct rtc_wkalrm alarm; in rtc_timer_remove() local
881 alarm.time = rtc_ktime_to_tm(next->expires); in rtc_timer_remove()
882 alarm.enabled = 1; in rtc_timer_remove()
883 err = __rtc_set_alarm(rtc, &alarm); in rtc_timer_remove()
895 * Expires rtc timers. Reprograms next alarm event if needed.
937 /* Set next alarm */ in rtc_timer_do_work()
939 struct rtc_wkalrm alarm; in rtc_timer_do_work() local
943 alarm.time = rtc_ktime_to_tm(next->expires); in rtc_timer_do_work()
944 alarm.enabled = 1; in rtc_timer_do_work()
946 err = __rtc_set_alarm(rtc, &alarm); in rtc_timer_do_work()