1 #ifndef _LINUX_TIME_HISTORY_H
2 #define _LINUX_TIME_HISTORY_H
4 #include <linux/ktime.h>
5 #include <linux/alarmtimer.h>
8 enum time_history_type {
9 TIME_HISTORY_TYPE_TIME_SET = 0,
10 TIME_HISTORY_TYPE_RTC_TIME_SET,
11 TIME_HISTORY_TYPE_HOST_TIME_SET,
12 TIME_HISTORY_TYPE_NETWORK_TIME_SET,
13 TIME_HISTORY_TYPE_TIMEZONE_SET,
14 TIME_HISTORY_TYPE_NITZ_UPDATE_SET,
15 TIME_HISTORY_TYPE_ALARM_START,
16 TIME_HISTORY_TYPE_ALARM_RESTART,
17 TIME_HISTORY_TYPE_ALARM_EXPIRED,
18 TIME_HISTORY_TYPE_ALARM_DEL,
19 TIME_HISTORY_TYPE_RTC_ALARM_SET,
20 TIME_HISTORY_TYPE_MAX,
23 #ifdef CONFIG_TIME_HISTORY
24 extern void __time_history_alarm_init(const struct alarm *alarm, void *caller);
25 extern void __time_history_alarm_start(const struct alarm *alarm, void *caller);
26 extern void __time_history_alarm_restart(const struct alarm *alarm, void *caller);
27 extern void __time_history_alarm_expired(const struct alarm *alarm, ktime_t now);
28 extern void __time_history_alarm_del(const struct alarm *alarm, void *caller);
29 extern void __time_history_time_set(const struct timespec *oldtime,
30 const struct timespec *newtime, void *caller);
31 extern void __time_history_rtc_time_set(const struct timespec *newtime,
32 void *caller, int err);
33 extern void __time_history_rtc_alarm_init(const struct rtc_timer *timer,
35 extern void __time_history_rtc_alarm_set(struct rtc_device *rtc,
36 const struct rtc_wkalrm *wkalrm, void *caller, int err);
38 static inline void time_history_alarm_init(const struct alarm *alarm)
43 __time_history_alarm_init(alarm, __builtin_return_address(0));
46 static inline void time_history_alarm_start(const struct alarm *alarm)
51 __time_history_alarm_start(alarm, __builtin_return_address(0));
54 static inline void time_history_alarm_restart(const struct alarm *alarm)
59 __time_history_alarm_restart(alarm, __builtin_return_address(0));
62 static inline void time_history_alarm_expired(const struct alarm *alarm,
68 __time_history_alarm_expired(alarm, now);
71 static inline void time_history_alarm_del(const struct alarm *alarm)
76 __time_history_alarm_del(alarm, __builtin_return_address(0));
79 static inline void time_history_time_set(const struct timespec *oldtime,
80 const struct timespec *newtime)
82 if (unlikely(!oldtime || !newtime))
86 __time_history_time_set(oldtime, newtime, __builtin_return_address(0));
89 static inline void time_history_rtc_time_set(const struct rtc_time *tm, int err)
91 struct timespec newtime;
96 newtime = ktime_to_timespec(rtc_tm_to_ktime(*tm));
97 __time_history_rtc_time_set(&newtime, __builtin_return_address(0), err);
100 static inline void time_history_rtc_alarm_init(struct rtc_timer *timer)
102 if (unlikely(!timer))
105 __time_history_rtc_alarm_init(timer, __builtin_return_address(0));
109 static inline void time_history_rtc_alarm_set(struct rtc_device *rtc,
110 struct rtc_wkalrm *wkalrm, int err)
112 if (unlikely(!rtc || !wkalrm))
115 __time_history_rtc_alarm_set(rtc, wkalrm, __builtin_return_address(0), err);
118 #else /* !CONFIG_TIME_HISTORY */
119 static inline void time_history_alarm_init(const struct alarm *alarm)
123 static inline void time_history_alarm_start(const struct alarm *alarm)
127 static inline void time_history_alarm_restart(const struct alarm *alarm)
131 static inline void time_history_alarm_expired(const struct alarm *alarm,
136 static inline void time_history_alarm_del(const struct alarm *alarm)
140 static inline void time_history_time_set(const struct timespec *oldtime,
141 const struct timespec *newtime)
145 static inline void time_history_rtc_time_set(const struct rtc_time *tm, int err)
149 static inline void time_history_rtc_alarm_init(struct rtc_timer *timer)
153 static inline void time_history_rtc_alarm_set(struct rtc_device *rtc,
154 struct rtc_wkalrm *wkalrm, int err)
158 #endif /* CONFIG_TIME_HISTORY */
160 #endif /* _LINUX_TIME_HISTORY_H */