alarmtimer.c (58e16d792a6a8c6b750f637a4649967fcac853dc) alarmtimer.c (ec8f954a40da8cd3d159713b608e901f0cd909a9)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Alarmtimer interface
4 *
5 * This interface provides a timer which is similarto hrtimers,
6 * but triggers a RTC alarm if the box is suspend.
7 *
8 * This interface is influenced by the Android RTC Alarm timer

--- 418 unchanged lines hidden (view full) ---

427 * Returns 1 if the timer was canceled, 0 if it was not active.
428 */
429int alarm_cancel(struct alarm *alarm)
430{
431 for (;;) {
432 int ret = alarm_try_to_cancel(alarm);
433 if (ret >= 0)
434 return ret;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Alarmtimer interface
4 *
5 * This interface provides a timer which is similarto hrtimers,
6 * but triggers a RTC alarm if the box is suspend.
7 *
8 * This interface is influenced by the Android RTC Alarm timer

--- 418 unchanged lines hidden (view full) ---

427 * Returns 1 if the timer was canceled, 0 if it was not active.
428 */
429int alarm_cancel(struct alarm *alarm)
430{
431 for (;;) {
432 int ret = alarm_try_to_cancel(alarm);
433 if (ret >= 0)
434 return ret;
435 cpu_relax();
435 hrtimer_cancel_wait_running(&alarm->timer);
436 }
437}
438EXPORT_SYMBOL_GPL(alarm_cancel);
439
440
441u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval)
442{
443 u64 overrun = 1;

--- 157 unchanged lines hidden (view full) ---

601 * @timr: Pointer to the posixtimer data struct
602 */
603static int alarm_timer_try_to_cancel(struct k_itimer *timr)
604{
605 return alarm_try_to_cancel(&timr->it.alarm.alarmtimer);
606}
607
608/**
436 }
437}
438EXPORT_SYMBOL_GPL(alarm_cancel);
439
440
441u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval)
442{
443 u64 overrun = 1;

--- 157 unchanged lines hidden (view full) ---

601 * @timr: Pointer to the posixtimer data struct
602 */
603static int alarm_timer_try_to_cancel(struct k_itimer *timr)
604{
605 return alarm_try_to_cancel(&timr->it.alarm.alarmtimer);
606}
607
608/**
609 * alarm_timer_wait_running - Posix timer callback to wait for a timer
610 * @timr: Pointer to the posixtimer data struct
611 *
612 * Called from the core code when timer cancel detected that the callback
613 * is running. @timr is unlocked and rcu read lock is held to prevent it
614 * from being freed.
615 */
616static void alarm_timer_wait_running(struct k_itimer *timr)
617{
618 hrtimer_cancel_wait_running(&timr->it.alarm.alarmtimer.timer);
619}
620
621/**
609 * alarm_timer_arm - Posix timer callback to arm a timer
610 * @timr: Pointer to the posixtimer data struct
611 * @expires: The new expiry time
612 * @absolute: Expiry value is absolute time
613 * @sigev_none: Posix timer does not deliver signals
614 */
615static void alarm_timer_arm(struct k_itimer *timr, ktime_t expires,
616 bool absolute, bool sigev_none)

--- 212 unchanged lines hidden (view full) ---

829 .timer_set = common_timer_set,
830 .timer_del = common_timer_del,
831 .timer_get = common_timer_get,
832 .timer_arm = alarm_timer_arm,
833 .timer_rearm = alarm_timer_rearm,
834 .timer_forward = alarm_timer_forward,
835 .timer_remaining = alarm_timer_remaining,
836 .timer_try_to_cancel = alarm_timer_try_to_cancel,
622 * alarm_timer_arm - Posix timer callback to arm a timer
623 * @timr: Pointer to the posixtimer data struct
624 * @expires: The new expiry time
625 * @absolute: Expiry value is absolute time
626 * @sigev_none: Posix timer does not deliver signals
627 */
628static void alarm_timer_arm(struct k_itimer *timr, ktime_t expires,
629 bool absolute, bool sigev_none)

--- 212 unchanged lines hidden (view full) ---

842 .timer_set = common_timer_set,
843 .timer_del = common_timer_del,
844 .timer_get = common_timer_get,
845 .timer_arm = alarm_timer_arm,
846 .timer_rearm = alarm_timer_rearm,
847 .timer_forward = alarm_timer_forward,
848 .timer_remaining = alarm_timer_remaining,
849 .timer_try_to_cancel = alarm_timer_try_to_cancel,
850 .timer_wait_running = alarm_timer_wait_running,
837 .nsleep = alarm_timer_nsleep,
838};
839#endif /* CONFIG_POSIX_TIMERS */
840
841
842/* Suspend hook structures */
843static const struct dev_pm_ops alarmtimer_pm_ops = {
844 .suspend = alarmtimer_suspend,

--- 56 unchanged lines hidden ---
851 .nsleep = alarm_timer_nsleep,
852};
853#endif /* CONFIG_POSIX_TIMERS */
854
855
856/* Suspend hook structures */
857static const struct dev_pm_ops alarmtimer_pm_ops = {
858 .suspend = alarmtimer_suspend,

--- 56 unchanged lines hidden ---