tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / linux / time_history.h
1 #ifndef _LINUX_TIME_HISTORY_H
2 #define _LINUX_TIME_HISTORY_H
3
4 #include <linux/ktime.h>
5 #include <linux/alarmtimer.h>
6 #include <linux/rtc.h>
7
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,
21 };
22
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,
34                 void *caller);
35 extern void __time_history_rtc_alarm_set(struct rtc_device *rtc,
36                 const struct rtc_wkalrm *wkalrm, void *caller, int err);
37
38 static inline void time_history_alarm_init(const struct alarm *alarm)
39 {
40         if (unlikely(!alarm))
41                 return;
42
43         __time_history_alarm_init(alarm, __builtin_return_address(0));
44 }
45
46 static inline void time_history_alarm_start(const struct alarm *alarm)
47 {
48         if (unlikely(!alarm))
49                 return;
50
51         __time_history_alarm_start(alarm, __builtin_return_address(0));
52 }
53
54 static inline void time_history_alarm_restart(const struct alarm *alarm)
55 {
56         if (unlikely(!alarm))
57                 return;
58
59         __time_history_alarm_restart(alarm, __builtin_return_address(0));
60 }
61
62 static inline void time_history_alarm_expired(const struct alarm *alarm,
63                 ktime_t now)
64 {
65         if (unlikely(!alarm))
66                 return;
67
68         __time_history_alarm_expired(alarm, now);
69 }
70
71 static inline void time_history_alarm_del(const struct alarm *alarm)
72 {
73         if (unlikely(!alarm))
74                 return;
75
76         __time_history_alarm_del(alarm, __builtin_return_address(0));
77 }
78
79 static inline void time_history_time_set(const struct timespec *oldtime,
80                 const struct timespec *newtime)
81 {
82         if (unlikely(!oldtime || !newtime))
83                 return;
84
85
86         __time_history_time_set(oldtime, newtime, __builtin_return_address(0));
87 }
88
89 static inline void time_history_rtc_time_set(const struct rtc_time *tm, int err)
90 {
91         struct timespec newtime;
92
93         if (unlikely(!tm))
94                 return;
95
96         newtime = ktime_to_timespec(rtc_tm_to_ktime(*tm));
97         __time_history_rtc_time_set(&newtime, __builtin_return_address(0), err);
98 }
99
100 static inline void time_history_rtc_alarm_init(struct rtc_timer *timer)
101 {
102         if (unlikely(!timer))
103                 return;
104
105         __time_history_rtc_alarm_init(timer, __builtin_return_address(0));
106         return;
107 }
108
109 static inline void time_history_rtc_alarm_set(struct rtc_device *rtc,
110                 struct rtc_wkalrm *wkalrm, int err)
111 {
112         if (unlikely(!rtc || !wkalrm))
113                 return;
114
115         __time_history_rtc_alarm_set(rtc, wkalrm, __builtin_return_address(0), err);
116         return;
117 }
118 #else /* !CONFIG_TIME_HISTORY */
119 static inline void time_history_alarm_init(const struct alarm *alarm)
120 {
121         return;
122 }
123 static inline void time_history_alarm_start(const struct alarm *alarm)
124 {
125         return;
126 }
127 static inline void time_history_alarm_restart(const struct alarm *alarm)
128 {
129         return;
130 }
131 static inline void time_history_alarm_expired(const struct alarm *alarm,
132                 ktime_t now)
133 {
134         return;
135 }
136 static inline void time_history_alarm_del(const struct alarm *alarm)
137 {
138         return;
139 }
140 static inline void time_history_time_set(const struct timespec *oldtime,
141                 const struct timespec *newtime)
142 {
143         return;
144 }
145 static inline void time_history_rtc_time_set(const struct rtc_time *tm, int err)
146 {
147         return;
148 }
149 static inline void time_history_rtc_alarm_init(struct rtc_timer *timer)
150 {
151         return;
152 }
153 static inline void time_history_rtc_alarm_set(struct rtc_device *rtc,
154                 struct rtc_wkalrm *wkalrm, int err)
155 {
156         return;
157 }
158 #endif /* CONFIG_TIME_HISTORY */
159
160 #endif /* _LINUX_TIME_HISTORY_H */