Lines Matching defs:alarm

179 				   struct rtc_wkalrm *alarm)
192 alarm->enabled = 0;
193 alarm->pending = 0;
194 alarm->time.tm_sec = -1;
195 alarm->time.tm_min = -1;
196 alarm->time.tm_hour = -1;
197 alarm->time.tm_mday = -1;
198 alarm->time.tm_mon = -1;
199 alarm->time.tm_year = -1;
200 alarm->time.tm_wday = -1;
201 alarm->time.tm_yday = -1;
202 alarm->time.tm_isdst = -1;
203 err = rtc->ops->read_alarm(rtc->dev.parent, alarm);
208 trace_rtc_read_alarm(err?0:rtc_tm_to_time64(&alarm->time), err);
212 int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
222 * creating invalid alarm->time values, for reasons like:
230 * to set up as e.g. "alarm 15 minutes after each hour".
235 * RTC driver prevents "periodic alarm" modes.
238 * may have wrapped in the interval since we read the RTC alarm,
242 * Reading the alarm and timestamp in the reverse sequence
246 * then read the RTC alarm value,
271 /* get the RTC alarm values, which may be incomplete */
272 err = rtc_read_alarm_internal(rtc, alarm);
277 err = rtc_valid_tm(&alarm->time);
292 /* Fill in the missing alarm fields using the timestamp; we
293 * know there's at least one since alarm->time is invalid.
295 if (alarm->time.tm_sec == -1)
296 alarm->time.tm_sec = now.tm_sec;
297 if (alarm->time.tm_min == -1)
298 alarm->time.tm_min = now.tm_min;
299 if (alarm->time.tm_hour == -1)
300 alarm->time.tm_hour = now.tm_hour;
303 if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) {
304 alarm->time.tm_mday = now.tm_mday;
307 if ((unsigned int)alarm->time.tm_mon >= 12) {
308 alarm->time.tm_mon = now.tm_mon;
312 if (alarm->time.tm_year == -1) {
313 alarm->time.tm_year = now.tm_year;
318 /* Can't proceed if alarm is still invalid after replacing
321 err = rtc_valid_tm(&alarm->time);
327 t_alm = rtc_tm_to_time64(&alarm->time);
332 /* 24 hour rollover ... if it's now 10am Monday, an alarm that
338 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day");
340 rtc_time64_to_tm(t_alm, &alarm->time);
343 /* Month rollover ... if it's the 31th, an alarm on the 3rd will
344 * be next month. An alarm matching on the 30th, 29th, or 28th
346 * this type of alarm.
349 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month");
351 if (alarm->time.tm_mon < 11) {
352 alarm->time.tm_mon++;
354 alarm->time.tm_mon = 0;
355 alarm->time.tm_year++;
357 days = rtc_month_days(alarm->time.tm_mon,
358 alarm->time.tm_year);
359 } while (days < alarm->time.tm_mday);
364 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year");
366 alarm->time.tm_year++;
367 } while (!is_leap_year(alarm->time.tm_year + 1900) &&
368 rtc_valid_tm(&alarm->time) != 0);
372 dev_warn(&rtc->dev, "alarm rollover not handled\n");
375 err = rtc_valid_tm(&alarm->time);
378 if (err && alarm->enabled)
379 dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
380 &alarm->time);
382 rtc_add_offset(rtc, &alarm->time);
388 * rtc_read_next_alarm - read the next expiring alarm
390 * @alarm: storage for the alarm information
392 * Read the next expiring alarm from the RTC timerqueue. This returns
393 * the alarm that will actually fire next, which may be different from
397 * Returns: 0 on success, -ENOENT if no alarm is pending, or other error.
399 int rtc_read_next_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
404 if (!rtc || !alarm)
417 memset(alarm, 0, sizeof(struct rtc_wkalrm));
418 alarm->time = rtc_ktime_to_tm(next->expires);
419 alarm->enabled = 1;
427 int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
439 memset(alarm, 0, sizeof(struct rtc_wkalrm));
440 alarm->enabled = rtc->aie_timer.enabled;
441 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires);
445 trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err);
450 static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
456 err = rtc_valid_tm(&alarm->time);
460 scheduled = rtc_tm_to_time64(&alarm->time);
471 * XXX - We just checked to make sure the alarm time is not
473 * the is alarm set for the next second and the second ticks
474 * over right here, before we set the alarm.
477 rtc_subtract_offset(rtc, &alarm->time);
484 err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
490 * 1) It ticked after the alarm was set, and an alarm irq should be
493 * 2) It ticked before the alarm was set, and alarm irq most likely will
509 trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err);
513 int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
523 err = rtc_valid_tm(&alarm->time);
527 err = rtc_valid_range(rtc, &alarm->time);
537 alarm_time = rtc_tm_to_ktime(alarm->time);
543 alarm_time = ktime_sub_ns(alarm_time, (u64)alarm->time.tm_sec * NSEC_PER_SEC);
547 if (alarm->enabled)
557 int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
562 err = rtc_valid_tm(&alarm->time);
574 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
578 if (alarm->enabled && (rtc_tm_to_ktime(now) <
864 * the next alarm event appropriately.
894 struct rtc_wkalrm alarm;
896 alarm.time = rtc_ktime_to_tm(timer->node.expires);
897 alarm.enabled = 1;
898 err = __rtc_set_alarm(rtc, &alarm);
927 * the next alarm event appropriately.
941 struct rtc_wkalrm alarm;
949 alarm.time = rtc_ktime_to_tm(next->expires);
950 alarm.enabled = 1;
951 err = __rtc_set_alarm(rtc, &alarm);
963 * Expires rtc timers. Reprograms next alarm event if needed.
1010 /* Set next alarm */
1012 struct rtc_wkalrm alarm;
1016 alarm.time = rtc_ktime_to_tm(next->expires);
1017 alarm.enabled = 1;
1019 err = __rtc_set_alarm(rtc, &alarm);