Add support for VT6415 PCIE PATA IDE Host Controller
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / timer.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_TIMER_H
2#define _LINUX_TIMER_H
3
1da177e4 4#include <linux/list.h>
82f67cd9 5#include <linux/ktime.h>
1da177e4 6#include <linux/stddef.h>
c6f3a97f 7#include <linux/debugobjects.h>
1da177e4 8
a6fa8e5a 9struct tvec_base;
1da177e4
LT
10
11struct timer_list {
12 struct list_head entry;
13 unsigned long expires;
14
1da177e4
LT
15 void (*function)(unsigned long);
16 unsigned long data;
17
a6fa8e5a 18 struct tvec_base *base;
82f67cd9
IM
19#ifdef CONFIG_TIMER_STATS
20 void *start_site;
21 char start_comm[16];
22 int start_pid;
23#endif
1da177e4
LT
24};
25
a6fa8e5a 26extern struct tvec_base boot_tvec_bases;
55c888d6 27
1da177e4 28#define TIMER_INITIALIZER(_function, _expires, _data) { \
c6f3a97f 29 .entry = { .prev = TIMER_ENTRY_STATIC }, \
1da177e4
LT
30 .function = (_function), \
31 .expires = (_expires), \
32 .data = (_data), \
3691c519 33 .base = &boot_tvec_bases, \
1da177e4
LT
34 }
35
8d06afab
IM
36#define DEFINE_TIMER(_name, _function, _expires, _data) \
37 struct timer_list _name = \
38 TIMER_INITIALIZER(_function, _expires, _data)
39
ec701584
HH
40void init_timer(struct timer_list *timer);
41void init_timer_deferrable(struct timer_list *timer);
1da177e4 42
c6f3a97f
TG
43#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
44extern void init_timer_on_stack(struct timer_list *timer);
45extern void destroy_timer_on_stack(struct timer_list *timer);
46#else
47static inline void destroy_timer_on_stack(struct timer_list *timer) { }
48static inline void init_timer_on_stack(struct timer_list *timer)
49{
50 init_timer(timer);
51}
52#endif
53
a8db2db1
ON
54static inline void setup_timer(struct timer_list * timer,
55 void (*function)(unsigned long),
56 unsigned long data)
57{
58 timer->function = function;
59 timer->data = data;
60 init_timer(timer);
61}
62
c6f3a97f
TG
63static inline void setup_timer_on_stack(struct timer_list *timer,
64 void (*function)(unsigned long),
65 unsigned long data)
66{
67 timer->function = function;
68 timer->data = data;
69 init_timer_on_stack(timer);
70}
71
45f8bde0 72/**
1da177e4
LT
73 * timer_pending - is a timer pending?
74 * @timer: the timer in question
75 *
76 * timer_pending will tell whether a given timer is currently pending,
77 * or not. Callers must ensure serialization wrt. other operations done
78 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
79 *
80 * return value: 1 if the timer is pending, 0 if not.
81 */
82static inline int timer_pending(const struct timer_list * timer)
83{
55c888d6 84 return timer->entry.next != NULL;
1da177e4
LT
85}
86
87extern void add_timer_on(struct timer_list *timer, int cpu);
88extern int del_timer(struct timer_list * timer);
89extern int __mod_timer(struct timer_list *timer, unsigned long expires);
90extern int mod_timer(struct timer_list *timer, unsigned long expires);
91
eaad084b
TG
92/*
93 * The jiffies value which is added to now, when there is no timer
94 * in the timer wheel:
95 */
96#define NEXT_TIMER_MAX_DELTA ((1UL << 30) - 1)
97
fd064b9b
TG
98/*
99 * Return when the next timer-wheel timeout occurs (in absolute jiffies),
100 * locks the timer base:
101 */
1da177e4 102extern unsigned long next_timer_interrupt(void);
fd064b9b
TG
103/*
104 * Return when the next timer-wheel timeout occurs (in absolute jiffies),
105 * locks the timer base and does the comparison against the given
106 * jiffie.
107 */
108extern unsigned long get_next_timer_interrupt(unsigned long now);
1da177e4 109
82f67cd9
IM
110/*
111 * Timer-statistics info:
112 */
113#ifdef CONFIG_TIMER_STATS
114
c5c061b8
VP
115#define TIMER_STATS_FLAG_DEFERRABLE 0x1
116
82f67cd9
IM
117extern void init_timer_stats(void);
118
119extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
c5c061b8
VP
120 void *timerf, char *comm,
121 unsigned int timer_flag);
82f67cd9
IM
122
123extern void __timer_stats_timer_set_start_info(struct timer_list *timer,
124 void *addr);
125
126static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
127{
128 __timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
129}
130
131static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
132{
133 timer->start_site = NULL;
134}
135#else
136static inline void init_timer_stats(void)
137{
138}
139
82f67cd9
IM
140static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
141{
142}
143
144static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
145{
146}
147#endif
148
45f8bde0 149/**
1da177e4
LT
150 * add_timer - start a timer
151 * @timer: the timer to be added
152 *
153 * The kernel will do a ->function(->data) callback from the
13fce806 154 * timer interrupt at the ->expires point in the future. The
1da177e4
LT
155 * current time is 'jiffies'.
156 *
13fce806 157 * The timer's ->expires, ->function (and if the handler uses it, ->data)
1da177e4
LT
158 * fields must be set prior calling this function.
159 *
13fce806 160 * Timers with an ->expires field in the past will be executed in the next
1da177e4
LT
161 * timer tick.
162 */
15d2bace 163static inline void add_timer(struct timer_list *timer)
1da177e4 164{
15d2bace 165 BUG_ON(timer_pending(timer));
1da177e4
LT
166 __mod_timer(timer, timer->expires);
167}
168
169#ifdef CONFIG_SMP
fd450b73 170 extern int try_to_del_timer_sync(struct timer_list *timer);
1da177e4 171 extern int del_timer_sync(struct timer_list *timer);
1da177e4 172#else
fd450b73
ON
173# define try_to_del_timer_sync(t) del_timer(t)
174# define del_timer_sync(t) del_timer(t)
1da177e4
LT
175#endif
176
55c888d6
ON
177#define del_singleshot_timer_sync(t) del_timer_sync(t)
178
1da177e4
LT
179extern void init_timers(void);
180extern void run_local_timers(void);
05cfb614 181struct hrtimer;
c9cb2e3d 182extern enum hrtimer_restart it_real_fn(struct hrtimer *);
1da177e4 183
4c36a5de
AV
184unsigned long __round_jiffies(unsigned long j, int cpu);
185unsigned long __round_jiffies_relative(unsigned long j, int cpu);
186unsigned long round_jiffies(unsigned long j);
187unsigned long round_jiffies_relative(unsigned long j);
188
9c133c46
AS
189unsigned long __round_jiffies_up(unsigned long j, int cpu);
190unsigned long __round_jiffies_up_relative(unsigned long j, int cpu);
191unsigned long round_jiffies_up(unsigned long j);
192unsigned long round_jiffies_up_relative(unsigned long j);
193
1da177e4 194#endif