diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 12:07:28 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 12:07:28 -0700 |
commit | 36f021b579d195cdc5fa6f3e2bab198b4bf70643 (patch) | |
tree | 96d3c97f5e5214d2aa7151c12a22a7eb345dbaa1 /arch/i386/kernel | |
parent | 215d06780d13fd7de629b02b61b7b7bf88ce5039 (diff) | |
parent | 1d72acf91abb327e25137ad2e371c1a788b34e45 (diff) | |
download | op-kernel-dev-36f021b579d195cdc5fa6f3e2bab198b4bf70643.zip op-kernel-dev-36f021b579d195cdc5fa6f3e2bab198b4bf70643.tar.gz |
Merge branch 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: (32 commits)
Use menuconfig objects - hwmon
hwmon/smsc47b397: Use dynamic sysfs callbacks
hwmon/smsc47b397: Convert to a platform driver
hwmon/w83781d: Deprecate W83627HF support
hwmon/w83781d: Use dynamic sysfs callbacks
hwmon/w83781d: Be less i2c_client-centric
hwmon/w83781d: Clean up conversion macros
hwmon/w83781d: No longer use i2c-isa
hwmon/ams: Do not print error on systems without apple motion sensor
hwmon/ams: Fix I2C read retry logic
hwmon: New AD7416, AD7417 and AD7418 driver
hwmon/coretemp: Add documentation
hwmon: New coretemp driver
i386: Use functions from library in msr driver
i386: Add safe variants of rdmsr_on_cpu and wrmsr_on_cpu
hwmon/lm75: Use dynamic sysfs callbacks
hwmon/lm78: Use dynamic sysfs callbacks
hwmon/lm78: Be less i2c_client-centric
hwmon/lm78: No longer use i2c-isa
hwmon: New max6650 driver
...
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r-- | arch/i386/kernel/msr.c | 106 |
1 files changed, 4 insertions, 102 deletions
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c index bcaa6e9..8cd0a91 100644 --- a/arch/i386/kernel/msr.c +++ b/arch/i386/kernel/msr.c @@ -45,104 +45,6 @@ static struct class *msr_class; -static inline int wrmsr_eio(u32 reg, u32 eax, u32 edx) -{ - int err; - - err = wrmsr_safe(reg, eax, edx); - if (err) - err = -EIO; - return err; -} - -static inline int rdmsr_eio(u32 reg, u32 *eax, u32 *edx) -{ - int err; - - err = rdmsr_safe(reg, eax, edx); - if (err) - err = -EIO; - return err; -} - -#ifdef CONFIG_SMP - -struct msr_command { - int err; - u32 reg; - u32 data[2]; -}; - -static void msr_smp_wrmsr(void *cmd_block) -{ - struct msr_command *cmd = (struct msr_command *)cmd_block; - - cmd->err = wrmsr_eio(cmd->reg, cmd->data[0], cmd->data[1]); -} - -static void msr_smp_rdmsr(void *cmd_block) -{ - struct msr_command *cmd = (struct msr_command *)cmd_block; - - cmd->err = rdmsr_eio(cmd->reg, &cmd->data[0], &cmd->data[1]); -} - -static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx) -{ - struct msr_command cmd; - int ret; - - preempt_disable(); - if (cpu == smp_processor_id()) { - ret = wrmsr_eio(reg, eax, edx); - } else { - cmd.reg = reg; - cmd.data[0] = eax; - cmd.data[1] = edx; - - smp_call_function_single(cpu, msr_smp_wrmsr, &cmd, 1, 1); - ret = cmd.err; - } - preempt_enable(); - return ret; -} - -static inline int do_rdmsr(int cpu, u32 reg, u32 * eax, u32 * edx) -{ - struct msr_command cmd; - int ret; - - preempt_disable(); - if (cpu == smp_processor_id()) { - ret = rdmsr_eio(reg, eax, edx); - } else { - cmd.reg = reg; - - smp_call_function_single(cpu, msr_smp_rdmsr, &cmd, 1, 1); - - *eax = cmd.data[0]; - *edx = cmd.data[1]; - - ret = cmd.err; - } - preempt_enable(); - return ret; -} - -#else /* ! CONFIG_SMP */ - -static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx) -{ - return wrmsr_eio(reg, eax, edx); -} - -static inline int do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx) -{ - return rdmsr_eio(reg, eax, edx); -} - -#endif /* ! CONFIG_SMP */ - static loff_t msr_seek(struct file *file, loff_t offset, int orig) { loff_t ret = -EINVAL; @@ -174,9 +76,9 @@ static ssize_t msr_read(struct file *file, char __user * buf, return -EINVAL; /* Invalid chunk size */ for (; count; count -= 8) { - err = do_rdmsr(cpu, reg, &data[0], &data[1]); + err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]); if (err) - return err; + return -EIO; if (copy_to_user(tmp, &data, 8)) return -EFAULT; tmp += 2; @@ -200,9 +102,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf, for (; count; count -= 8) { if (copy_from_user(&data, tmp, 8)) return -EFAULT; - err = do_wrmsr(cpu, reg, data[0], data[1]); + err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]); if (err) - return err; + return -EIO; tmp += 2; } |