Lines Matching refs: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(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 if (rtc_valid_tm(&alarm->time) == 0) {
278 rtc_add_offset(rtc, &alarm->time);
293 /* Fill in the missing alarm fields using the timestamp; we
294 * know there's at least one since alarm->time is invalid.
296 if (alarm->time.tm_sec == -1)
297 alarm->time.tm_sec = now.tm_sec;
298 if (alarm->time.tm_min == -1)
299 alarm->time.tm_min = now.tm_min;
300 if (alarm->time.tm_hour == -1)
301 alarm->time.tm_hour = now.tm_hour;
304 if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) {
305 alarm->time.tm_mday = now.tm_mday;
308 if ((unsigned int)alarm->time.tm_mon >= 12) {
309 alarm->time.tm_mon = now.tm_mon;
313 if (alarm->time.tm_year == -1) {
314 alarm->time.tm_year = now.tm_year;
319 /* Can't proceed if alarm is still invalid after replacing
322 err = rtc_valid_tm(&alarm->time);
328 t_alm = rtc_tm_to_time64(&alarm->time);
333 /* 24 hour rollover ... if it's now 10am Monday, an alarm that
339 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day");
341 rtc_time64_to_tm(t_alm, &alarm->time);
344 /* Month rollover ... if it's the 31th, an alarm on the 3rd will
345 * be next month. An alarm matching on the 30th, 29th, or 28th
347 * this type of alarm.
350 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month");
352 if (alarm->time.tm_mon < 11) {
353 alarm->time.tm_mon++;
355 alarm->time.tm_mon = 0;
356 alarm->time.tm_year++;
358 days = rtc_month_days(alarm->time.tm_mon,
359 alarm->time.tm_year);
360 } while (days < alarm->time.tm_mday);
365 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year");
367 alarm->time.tm_year++;
368 } while (!is_leap_year(alarm->time.tm_year + 1900) &&
369 rtc_valid_tm(&alarm->time) != 0);
373 dev_warn(&rtc->dev, "alarm rollover not handled\n");
376 err = rtc_valid_tm(&alarm->time);
379 if (err && alarm->enabled)
380 dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
381 &alarm->time);
386 int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
398 memset(alarm, 0, sizeof(struct rtc_wkalrm));
399 alarm->enabled = rtc->aie_timer.enabled;
400 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires);
404 trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err);
409 static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
415 err = rtc_valid_tm(&alarm->time);
419 scheduled = rtc_tm_to_time64(&alarm->time);
430 * XXX - We just checked to make sure the alarm time is not
432 * the is alarm set for the next second and the second ticks
433 * over right here, before we set the alarm.
436 rtc_subtract_offset(rtc, &alarm->time);
443 err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
445 trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err);
449 int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
459 err = rtc_valid_tm(&alarm->time);
463 err = rtc_valid_range(rtc, &alarm->time);
473 alarm_time = rtc_tm_to_ktime(alarm->time);
479 alarm_time = ktime_sub_ns(alarm_time, (u64)alarm->time.tm_sec * NSEC_PER_SEC);
483 if (alarm->enabled)
493 int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
498 err = rtc_valid_tm(&alarm->time);
510 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
514 if (alarm->enabled && (rtc_tm_to_ktime(now) <
796 * the next alarm event appropriately.
826 struct rtc_wkalrm alarm;
828 alarm.time = rtc_ktime_to_tm(timer->node.expires);
829 alarm.enabled = 1;
830 err = __rtc_set_alarm(rtc, &alarm);
859 * the next alarm event appropriately.
873 struct rtc_wkalrm alarm;
881 alarm.time = rtc_ktime_to_tm(next->expires);
882 alarm.enabled = 1;
883 err = __rtc_set_alarm(rtc, &alarm);
895 * Expires rtc timers. Reprograms next alarm event if needed.
937 /* Set next alarm */
939 struct rtc_wkalrm alarm;
943 alarm.time = rtc_ktime_to_tm(next->expires);
944 alarm.enabled = 1;
946 err = __rtc_set_alarm(rtc, &alarm);