]> Git Repo - J-linux.git/blob - include/linux/alarmtimer.h
Merge tag 'riscv-for-linus-6.13-mw1' of git://git.kernel.org/pub/scm/linux/kernel...
[J-linux.git] / include / linux / alarmtimer.h
1 /* SPDX-License-Identifier: GPL-2.0 */
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>
8
9 struct rtc_device;
10
11 enum alarmtimer_type {
12         ALARM_REALTIME,
13         ALARM_BOOTTIME,
14
15         /* Supported types end here */
16         ALARM_NUMTYPE,
17
18         /* Used for tracing information. No usable types. */
19         ALARM_REALTIME_FREEZER,
20         ALARM_BOOTTIME_FREEZER,
21 };
22
23 #define ALARMTIMER_STATE_INACTIVE       0x00
24 #define ALARMTIMER_STATE_ENQUEUED       0x01
25
26 /**
27  * struct alarm - Alarm timer structure
28  * @node:       timerqueue node for adding to the event list this value
29  *              also includes the expiration time.
30  * @timer:      hrtimer used to schedule events while running
31  * @function:   Function pointer to be executed when the timer fires.
32  * @type:       Alarm type (BOOTTIME/REALTIME).
33  * @state:      Flag that represents if the alarm is set to fire or not.
34  * @data:       Internal data value.
35  */
36 struct alarm {
37         struct timerqueue_node  node;
38         struct hrtimer          timer;
39         void                    (*function)(struct alarm *, ktime_t now);
40         enum alarmtimer_type    type;
41         int                     state;
42         void                    *data;
43 };
44
45 void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
46                 void (*function)(struct alarm *, ktime_t));
47 void alarm_start(struct alarm *alarm, ktime_t start);
48 void alarm_start_relative(struct alarm *alarm, ktime_t start);
49 void alarm_restart(struct alarm *alarm);
50 int alarm_try_to_cancel(struct alarm *alarm);
51 int alarm_cancel(struct alarm *alarm);
52
53 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
54 u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
55 ktime_t alarm_expires_remaining(const struct alarm *alarm);
56
57 #ifdef CONFIG_RTC_CLASS
58 /* Provide way to access the rtc device being used by alarmtimers */
59 struct rtc_device *alarmtimer_get_rtcdev(void);
60 #else
61 static inline struct rtc_device *alarmtimer_get_rtcdev(void) { return NULL; }
62 #endif
63
64 #endif
This page took 0.030534 seconds and 4 git commands to generate.