mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 18:23:53 +08:00
dce75a8c71
In order to avoid wasting time expiring and re-adding very high freq periodic alarmtimers, introduce alarm_forward() which is similar to hrtimer_forward and moves the timer to the next future expiration time and returns the number of overruns. CC: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
#ifndef _LINUX_ALARMTIMER_H
|
|
#define _LINUX_ALARMTIMER_H
|
|
|
|
#include <linux/time.h>
|
|
#include <linux/hrtimer.h>
|
|
#include <linux/timerqueue.h>
|
|
#include <linux/rtc.h>
|
|
|
|
enum alarmtimer_type {
|
|
ALARM_REALTIME,
|
|
ALARM_BOOTTIME,
|
|
|
|
ALARM_NUMTYPE,
|
|
};
|
|
|
|
enum alarmtimer_restart {
|
|
ALARMTIMER_NORESTART,
|
|
ALARMTIMER_RESTART,
|
|
};
|
|
|
|
/**
|
|
* struct alarm - Alarm timer structure
|
|
* @node: timerqueue node for adding to the event list this value
|
|
* also includes the expiration time.
|
|
* @period: Period for recuring alarms
|
|
* @function: Function pointer to be executed when the timer fires.
|
|
* @type: Alarm type (BOOTTIME/REALTIME)
|
|
* @enabled: Flag that represents if the alarm is set to fire or not
|
|
* @data: Internal data value.
|
|
*/
|
|
struct alarm {
|
|
struct timerqueue_node node;
|
|
ktime_t period;
|
|
enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
|
|
enum alarmtimer_type type;
|
|
bool enabled;
|
|
void *data;
|
|
};
|
|
|
|
void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
|
|
enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
|
|
void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
|
|
void alarm_cancel(struct alarm *alarm);
|
|
|
|
u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
|
|
|
|
#endif
|