OMAP: DISPC: Fix to disable also interface clocks. 2nd.
[linux-ginger.git] / arch / x86 / lib / msr-on-cpu.c
blob57d043fa893e48f9a2412a479cb01445ab1d1122
1 #include <linux/module.h>
2 #include <linux/preempt.h>
3 #include <linux/smp.h>
4 #include <asm/msr.h>
6 struct msr_info {
7 u32 msr_no;
8 u32 l, h;
9 int err;
12 static void __rdmsr_on_cpu(void *info)
14 struct msr_info *rv = info;
16 rdmsr(rv->msr_no, rv->l, rv->h);
19 static void __rdmsr_safe_on_cpu(void *info)
21 struct msr_info *rv = info;
23 rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h);
26 static int _rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h, int safe)
28 int err = 0;
29 struct msr_info rv;
31 rv.msr_no = msr_no;
32 if (safe) {
33 smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 0, 1);
34 err = rv.err;
35 } else {
36 smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 0, 1);
38 *l = rv.l;
39 *h = rv.h;
41 return err;
44 static void __wrmsr_on_cpu(void *info)
46 struct msr_info *rv = info;
48 wrmsr(rv->msr_no, rv->l, rv->h);
51 static void __wrmsr_safe_on_cpu(void *info)
53 struct msr_info *rv = info;
55 rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h);
58 static int _wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h, int safe)
60 int err = 0;
61 struct msr_info rv;
63 rv.msr_no = msr_no;
64 rv.l = l;
65 rv.h = h;
66 if (safe) {
67 smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 0, 1);
68 err = rv.err;
69 } else {
70 smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 0, 1);
73 return err;
76 void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
78 _wrmsr_on_cpu(cpu, msr_no, l, h, 0);
81 void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
83 _rdmsr_on_cpu(cpu, msr_no, l, h, 0);
86 /* These "safe" variants are slower and should be used when the target MSR
87 may not actually exist. */
88 int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
90 return _wrmsr_on_cpu(cpu, msr_no, l, h, 1);
93 int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
95 return _rdmsr_on_cpu(cpu, msr_no, l, h, 1);
98 EXPORT_SYMBOL(rdmsr_on_cpu);
99 EXPORT_SYMBOL(wrmsr_on_cpu);
100 EXPORT_SYMBOL(rdmsr_safe_on_cpu);
101 EXPORT_SYMBOL(wrmsr_safe_on_cpu);