up.c: use local_irq_{save,restore}() in smp_call_function_single.
[pandora-kernel.git] / kernel / up.c
1 /*
2  * Uniprocessor-only support functions.  The counterpart to kernel/smp.c
3  */
4
5 #include <linux/interrupt.h>
6 #include <linux/kernel.h>
7 #include <linux/export.h>
8 #include <linux/smp.h>
9
10 int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
11                                 int wait)
12 {
13         unsigned long flags;
14
15         WARN_ON(cpu != 0);
16
17         local_irq_save(flags);
18         func(info);
19         local_irq_restore(flags);
20
21         return 0;
22 }
23 EXPORT_SYMBOL(smp_call_function_single);
24
25 /*
26  * Note we still need to test the mask even for UP
27  * because we actually can get an empty mask from
28  * code that on SMP might call us without the local
29  * CPU in the mask.
30  */
31 void on_each_cpu_mask(const struct cpumask *mask,
32                       smp_call_func_t func, void *info, bool wait)
33 {
34         unsigned long flags;
35
36         if (cpumask_test_cpu(0, mask)) {
37                 local_irq_save(flags);
38                 func(info);
39                 local_irq_restore(flags);
40         }
41 }
42 EXPORT_SYMBOL(on_each_cpu_mask);
43
44 /*
45  * Preemption is disabled here to make sure the cond_func is called under the
46  * same condtions in UP and SMP.
47  */
48 void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
49                       smp_call_func_t func, void *info, bool wait,
50                       gfp_t gfp_flags)
51 {
52         unsigned long flags;
53
54         preempt_disable();
55         if (cond_func(0, info)) {
56                 local_irq_save(flags);
57                 func(info);
58                 local_irq_restore(flags);
59         }
60         preempt_enable();
61 }
62 EXPORT_SYMBOL(on_each_cpu_cond);