[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable...
[linux-2.6/verdex.git] / include / linux / timer.h
blob90db1cc62ddd02875918840b129945aff45df56e
1 #ifndef _LINUX_TIMER_H
2 #define _LINUX_TIMER_H
4 #include <linux/config.h>
5 #include <linux/list.h>
6 #include <linux/spinlock.h>
7 #include <linux/stddef.h>
9 struct tvec_t_base_s;
11 struct timer_list {
12 struct list_head entry;
13 unsigned long expires;
15 spinlock_t lock;
16 unsigned long magic;
18 void (*function)(unsigned long);
19 unsigned long data;
21 struct tvec_t_base_s *base;
24 #define TIMER_MAGIC 0x4b87ad6e
26 #define TIMER_INITIALIZER(_function, _expires, _data) { \
27 .function = (_function), \
28 .expires = (_expires), \
29 .data = (_data), \
30 .base = NULL, \
31 .magic = TIMER_MAGIC, \
32 .lock = SPIN_LOCK_UNLOCKED, \
35 /***
36 * init_timer - initialize a timer.
37 * @timer: the timer to be initialized
39 * init_timer() must be done to a timer prior calling *any* of the
40 * other timer functions.
42 static inline void init_timer(struct timer_list * timer)
44 timer->base = NULL;
45 timer->magic = TIMER_MAGIC;
46 spin_lock_init(&timer->lock);
49 /***
50 * timer_pending - is a timer pending?
51 * @timer: the timer in question
53 * timer_pending will tell whether a given timer is currently pending,
54 * or not. Callers must ensure serialization wrt. other operations done
55 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
57 * return value: 1 if the timer is pending, 0 if not.
59 static inline int timer_pending(const struct timer_list * timer)
61 return timer->base != NULL;
64 extern void add_timer_on(struct timer_list *timer, int cpu);
65 extern int del_timer(struct timer_list * timer);
66 extern int __mod_timer(struct timer_list *timer, unsigned long expires);
67 extern int mod_timer(struct timer_list *timer, unsigned long expires);
69 extern unsigned long next_timer_interrupt(void);
71 /***
72 * add_timer - start a timer
73 * @timer: the timer to be added
75 * The kernel will do a ->function(->data) callback from the
76 * timer interrupt at the ->expired point in the future. The
77 * current time is 'jiffies'.
79 * The timer's ->expired, ->function (and if the handler uses it, ->data)
80 * fields must be set prior calling this function.
82 * Timers with an ->expired field in the past will be executed in the next
83 * timer tick.
85 static inline void add_timer(struct timer_list * timer)
87 __mod_timer(timer, timer->expires);
90 #ifdef CONFIG_SMP
91 extern int del_timer_sync(struct timer_list *timer);
92 extern int del_singleshot_timer_sync(struct timer_list *timer);
93 #else
94 # define del_timer_sync(t) del_timer(t)
95 # define del_singleshot_timer_sync(t) del_timer(t)
96 #endif
98 extern void init_timers(void);
99 extern void run_local_timers(void);
100 extern void it_real_fn(unsigned long);
102 #endif