[CIFS] fix regression in cifs_write_begin/cifs_write_end
[linux-2.6/mini2440.git] / include / linux / timer.h
blobdaf9685b861c05143b17c529b1b72e77aa49c4ee
1 #ifndef _LINUX_TIMER_H
2 #define _LINUX_TIMER_H
4 #include <linux/list.h>
5 #include <linux/ktime.h>
6 #include <linux/stddef.h>
7 #include <linux/debugobjects.h>
9 struct tvec_base;
11 struct timer_list {
12 struct list_head entry;
13 unsigned long expires;
15 void (*function)(unsigned long);
16 unsigned long data;
18 struct tvec_base *base;
19 #ifdef CONFIG_TIMER_STATS
20 void *start_site;
21 char start_comm[16];
22 int start_pid;
23 #endif
26 extern struct tvec_base boot_tvec_bases;
28 #define TIMER_INITIALIZER(_function, _expires, _data) { \
29 .entry = { .prev = TIMER_ENTRY_STATIC }, \
30 .function = (_function), \
31 .expires = (_expires), \
32 .data = (_data), \
33 .base = &boot_tvec_bases, \
36 #define DEFINE_TIMER(_name, _function, _expires, _data) \
37 struct timer_list _name = \
38 TIMER_INITIALIZER(_function, _expires, _data)
40 void init_timer(struct timer_list *timer);
41 void init_timer_deferrable(struct timer_list *timer);
43 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
44 extern void init_timer_on_stack(struct timer_list *timer);
45 extern void destroy_timer_on_stack(struct timer_list *timer);
46 #else
47 static inline void destroy_timer_on_stack(struct timer_list *timer) { }
48 static inline void init_timer_on_stack(struct timer_list *timer)
50 init_timer(timer);
52 #endif
54 static inline void setup_timer(struct timer_list * timer,
55 void (*function)(unsigned long),
56 unsigned long data)
58 timer->function = function;
59 timer->data = data;
60 init_timer(timer);
63 static inline void setup_timer_on_stack(struct timer_list *timer,
64 void (*function)(unsigned long),
65 unsigned long data)
67 timer->function = function;
68 timer->data = data;
69 init_timer_on_stack(timer);
72 /**
73 * timer_pending - is a timer pending?
74 * @timer: the timer in question
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.
80 * return value: 1 if the timer is pending, 0 if not.
82 static inline int timer_pending(const struct timer_list * timer)
84 return timer->entry.next != NULL;
87 extern void add_timer_on(struct timer_list *timer, int cpu);
88 extern int del_timer(struct timer_list * timer);
89 extern int __mod_timer(struct timer_list *timer, unsigned long expires);
90 extern int mod_timer(struct timer_list *timer, unsigned long expires);
93 * The jiffies value which is added to now, when there is no timer
94 * in the timer wheel:
96 #define NEXT_TIMER_MAX_DELTA ((1UL << 30) - 1)
99 * Return when the next timer-wheel timeout occurs (in absolute jiffies),
100 * locks the timer base:
102 extern unsigned long next_timer_interrupt(void);
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.
108 extern unsigned long get_next_timer_interrupt(unsigned long now);
111 * Timer-statistics info:
113 #ifdef CONFIG_TIMER_STATS
115 #define TIMER_STATS_FLAG_DEFERRABLE 0x1
117 extern void init_timer_stats(void);
119 extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
120 void *timerf, char *comm,
121 unsigned int timer_flag);
123 extern void __timer_stats_timer_set_start_info(struct timer_list *timer,
124 void *addr);
126 static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
128 __timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
131 static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
133 timer->start_site = NULL;
135 #else
136 static inline void init_timer_stats(void)
140 static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
144 static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
147 #endif
150 * add_timer - start a timer
151 * @timer: the timer to be added
153 * The kernel will do a ->function(->data) callback from the
154 * timer interrupt at the ->expires point in the future. The
155 * current time is 'jiffies'.
157 * The timer's ->expires, ->function (and if the handler uses it, ->data)
158 * fields must be set prior calling this function.
160 * Timers with an ->expires field in the past will be executed in the next
161 * timer tick.
163 static inline void add_timer(struct timer_list *timer)
165 BUG_ON(timer_pending(timer));
166 __mod_timer(timer, timer->expires);
169 #ifdef CONFIG_SMP
170 extern int try_to_del_timer_sync(struct timer_list *timer);
171 extern int del_timer_sync(struct timer_list *timer);
172 #else
173 # define try_to_del_timer_sync(t) del_timer(t)
174 # define del_timer_sync(t) del_timer(t)
175 #endif
177 #define del_singleshot_timer_sync(t) del_timer_sync(t)
179 extern void init_timers(void);
180 extern void run_local_timers(void);
181 struct hrtimer;
182 extern enum hrtimer_restart it_real_fn(struct hrtimer *);
184 unsigned long __round_jiffies(unsigned long j, int cpu);
185 unsigned long __round_jiffies_relative(unsigned long j, int cpu);
186 unsigned long round_jiffies(unsigned long j);
187 unsigned long round_jiffies_relative(unsigned long j);
189 unsigned long __round_jiffies_up(unsigned long j, int cpu);
190 unsigned long __round_jiffies_up_relative(unsigned long j, int cpu);
191 unsigned long round_jiffies_up(unsigned long j);
192 unsigned long round_jiffies_up_relative(unsigned long j);
194 #endif