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 err = rtc_valid_tm(&alarm->time); in __rtc_read_alarm()
292 /* Fill in the missing alarm fields using the timestamp; we in __rtc_read_alarm()
293 * know there's at least one since alarm->time is invalid. in __rtc_read_alarm()
295 if (alarm->time.tm_sec == -1) in __rtc_read_alarm()
296 alarm->time.tm_sec = now.tm_sec; in __rtc_read_alarm()
297 if (alarm->time.tm_min == -1) in __rtc_read_alarm()
298 alarm->time.tm_min = now.tm_min; in __rtc_read_alarm()
299 if (alarm->time.tm_hour == -1) in __rtc_read_alarm()
300 alarm->time.tm_hour = now.tm_hour; in __rtc_read_alarm()
303 if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) { in __rtc_read_alarm()
304 alarm->time.tm_mday = now.tm_mday; in __rtc_read_alarm()
307 if ((unsigned int)alarm->time.tm_mon >= 12) { in __rtc_read_alarm()
308 alarm->time.tm_mon = now.tm_mon; in __rtc_read_alarm()
312 if (alarm->time.tm_year == -1) { in __rtc_read_alarm()
313 alarm->time.tm_year = now.tm_year; in __rtc_read_alarm()
318 /* Can't proceed if alarm is still invalid after replacing in __rtc_read_alarm()
321 err = rtc_valid_tm(&alarm->time); in __rtc_read_alarm()
327 t_alm = rtc_tm_to_time64(&alarm->time); in __rtc_read_alarm()
332 /* 24 hour rollover ... if it's now 10am Monday, an alarm that in __rtc_read_alarm()
338 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); in __rtc_read_alarm()
340 rtc_time64_to_tm(t_alm, &alarm->time); in __rtc_read_alarm()
343 /* Month rollover ... if it's the 31th, an alarm on the 3rd will in __rtc_read_alarm()
344 * be next month. An alarm matching on the 30th, 29th, or 28th in __rtc_read_alarm()
346 * this type of alarm. in __rtc_read_alarm()
349 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month"); in __rtc_read_alarm()
351 if (alarm->time.tm_mon < 11) { in __rtc_read_alarm()
352 alarm->time.tm_mon++; in __rtc_read_alarm()
354 alarm->time.tm_mon = 0; in __rtc_read_alarm()
355 alarm->time.tm_year++; in __rtc_read_alarm()
357 days = rtc_month_days(alarm->time.tm_mon, in __rtc_read_alarm()
358 alarm->time.tm_year); in __rtc_read_alarm()
359 } while (days < alarm->time.tm_mday); in __rtc_read_alarm()
364 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); in __rtc_read_alarm()
366 alarm->time.tm_year++; in __rtc_read_alarm()
367 } while (!is_leap_year(alarm->time.tm_year + 1900) && in __rtc_read_alarm()
368 rtc_valid_tm(&alarm->time) != 0); in __rtc_read_alarm()
372 dev_warn(&rtc->dev, "alarm rollover not handled\n"); in __rtc_read_alarm()
375 err = rtc_valid_tm(&alarm->time); in __rtc_read_alarm()
378 if (err && alarm->enabled) in __rtc_read_alarm()
379 dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", in __rtc_read_alarm()
380 &alarm->time); in __rtc_read_alarm()
382 rtc_add_offset(rtc, &alarm->time); in __rtc_read_alarm()
387 int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in rtc_read_alarm() argument
399 memset(alarm, 0, sizeof(struct rtc_wkalrm)); in rtc_read_alarm()
400 alarm->enabled = rtc->aie_timer.enabled; in rtc_read_alarm()
401 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); in rtc_read_alarm()
405 trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err); in rtc_read_alarm()
410 static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in __rtc_set_alarm() argument
416 err = rtc_valid_tm(&alarm->time); in __rtc_set_alarm()
420 scheduled = rtc_tm_to_time64(&alarm->time); in __rtc_set_alarm()
431 * XXX - We just checked to make sure the alarm time is not in __rtc_set_alarm()
433 * the is alarm set for the next second and the second ticks in __rtc_set_alarm()
434 * over right here, before we set the alarm. in __rtc_set_alarm()
437 rtc_subtract_offset(rtc, &alarm->time); in __rtc_set_alarm()
444 err = rtc->ops->set_alarm(rtc->dev.parent, alarm); in __rtc_set_alarm()
446 trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err); in __rtc_set_alarm()
450 int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in rtc_set_alarm() argument
460 err = rtc_valid_tm(&alarm->time); in rtc_set_alarm()
464 err = rtc_valid_range(rtc, &alarm->time); in rtc_set_alarm()
474 alarm_time = rtc_tm_to_ktime(alarm->time); in rtc_set_alarm()
480 alarm_time = ktime_sub_ns(alarm_time, (u64)alarm->time.tm_sec * NSEC_PER_SEC); in rtc_set_alarm()
484 if (alarm->enabled) in rtc_set_alarm()
494 int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) in rtc_initialize_alarm() argument
499 err = rtc_valid_tm(&alarm->time); in rtc_initialize_alarm()
511 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); in rtc_initialize_alarm()
514 /* Alarm has to be enabled & in the future for us to enqueue it */ in rtc_initialize_alarm()
515 if (alarm->enabled && (rtc_tm_to_ktime(now) < in rtc_initialize_alarm()
797 * the next alarm event appropriately.
827 struct rtc_wkalrm alarm; in rtc_timer_enqueue() local
829 alarm.time = rtc_ktime_to_tm(timer->node.expires); in rtc_timer_enqueue()
830 alarm.enabled = 1; in rtc_timer_enqueue()
831 err = __rtc_set_alarm(rtc, &alarm); in rtc_timer_enqueue()
860 * the next alarm event appropriately.
874 struct rtc_wkalrm alarm; in rtc_timer_remove() local
882 alarm.time = rtc_ktime_to_tm(next->expires); in rtc_timer_remove()
883 alarm.enabled = 1; in rtc_timer_remove()
884 err = __rtc_set_alarm(rtc, &alarm); in rtc_timer_remove()
896 * Expires rtc timers. Reprograms next alarm event if needed.
943 /* Set next alarm */ in rtc_timer_do_work()
945 struct rtc_wkalrm alarm; in rtc_timer_do_work() local
949 alarm.time = rtc_ktime_to_tm(next->expires); in rtc_timer_do_work()
950 alarm.enabled = 1; in rtc_timer_do_work()
952 err = __rtc_set_alarm(rtc, &alarm); in rtc_timer_do_work()