Input: ts4800-ts - switch to using polled mode of input devices
[linux-2.6-block.git] / include / linux / alarmtimer.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
ff3ead96
JS
2#ifndef _LINUX_ALARMTIMER_H
3#define _LINUX_ALARMTIMER_H
4
5#include <linux/time.h>
6#include <linux/hrtimer.h>
7#include <linux/timerqueue.h>
3758b0f8
TG
8
9struct rtc_device;
ff3ead96
JS
10
11enum alarmtimer_type {
12 ALARM_REALTIME,
13 ALARM_BOOTTIME,
14
4a057549 15 /* Supported types end here */
ff3ead96 16 ALARM_NUMTYPE,
4a057549
BW
17
18 /* Used for tracing information. No usable types. */
19 ALARM_REALTIME_FREEZER,
20 ALARM_BOOTTIME_FREEZER,
ff3ead96
JS
21};
22
4b41308d
JS
23enum alarmtimer_restart {
24 ALARMTIMER_NORESTART,
25 ALARMTIMER_RESTART,
26};
27
a28cde81
JS
28
29#define ALARMTIMER_STATE_INACTIVE 0x00
30#define ALARMTIMER_STATE_ENQUEUED 0x01
a28cde81 31
180bf812
JS
32/**
33 * struct alarm - Alarm timer structure
34 * @node: timerqueue node for adding to the event list this value
35 * also includes the expiration time.
af4afb40 36 * @timer: hrtimer used to schedule events while running
180bf812 37 * @function: Function pointer to be executed when the timer fires.
af4afb40
PP
38 * @type: Alarm type (BOOTTIME/REALTIME).
39 * @state: Flag that represents if the alarm is set to fire or not.
180bf812
JS
40 * @data: Internal data value.
41 */
ff3ead96
JS
42struct alarm {
43 struct timerqueue_node node;
dae373be 44 struct hrtimer timer;
4b41308d 45 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
ff3ead96 46 enum alarmtimer_type type;
a28cde81 47 int state;
ff3ead96
JS
48 void *data;
49};
50
51void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
4b41308d 52 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
b193217e
TG
53void alarm_start(struct alarm *alarm, ktime_t start);
54void alarm_start_relative(struct alarm *alarm, ktime_t start);
6cffe00f 55void alarm_restart(struct alarm *alarm);
9082c465
JS
56int alarm_try_to_cancel(struct alarm *alarm);
57int alarm_cancel(struct alarm *alarm);
ff3ead96 58
dce75a8c 59u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
6cffe00f
TP
60u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
61ktime_t alarm_expires_remaining(const struct alarm *alarm);
dce75a8c 62
57c498fa
JS
63/* Provide way to access the rtc device being used by alarmtimers */
64struct rtc_device *alarmtimer_get_rtcdev(void);
65
ff3ead96 66#endif