提交 5119e92e 编写于 作者: J Jonathan Corbet

x86: cdev lock_kernel() pushdown

Push the cdev lock_kernel() call down into the x86 msr and cpuid drivers.
Signed-off-by: NJonathan Corbet <corbet@lwn.net>
上级 1fa984b5
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/major.h> #include <linux/major.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
...@@ -107,15 +108,23 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, ...@@ -107,15 +108,23 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
static int cpuid_open(struct inode *inode, struct file *file) static int cpuid_open(struct inode *inode, struct file *file)
{ {
unsigned int cpu = iminor(file->f_path.dentry->d_inode); unsigned int cpu;
struct cpuinfo_x86 *c = &cpu_data(cpu); struct cpuinfo_x86 *c;
int ret = 0;
if (cpu >= NR_CPUS || !cpu_online(cpu))
return -ENXIO; /* No such CPU */ lock_kernel();
cpu = iminor(file->f_path.dentry->d_inode);
if (cpu >= NR_CPUS || !cpu_online(cpu)) {
ret = -ENXIO; /* No such CPU */
goto out;
}
c = &cpu_data(cpu);
if (c->cpuid_level < 0) if (c->cpuid_level < 0)
return -EIO; /* CPUID not supported */ ret = -EIO; /* CPUID not supported */
out:
return 0; unlock_kernel();
return ret;
} }
/* /*
......
...@@ -117,12 +117,20 @@ static int msr_open(struct inode *inode, struct file *file) ...@@ -117,12 +117,20 @@ static int msr_open(struct inode *inode, struct file *file)
{ {
unsigned int cpu = iminor(file->f_path.dentry->d_inode); unsigned int cpu = iminor(file->f_path.dentry->d_inode);
struct cpuinfo_x86 *c = &cpu_data(cpu); struct cpuinfo_x86 *c = &cpu_data(cpu);
int ret = 0;
if (cpu >= NR_CPUS || !cpu_online(cpu)) lock_kernel();
return -ENXIO; /* No such CPU */ cpu = iminor(file->f_path.dentry->d_inode);
if (!cpu_has(c, X86_FEATURE_MSR))
return -EIO; /* MSR not supported */
if (cpu >= NR_CPUS || !cpu_online(cpu)) {
ret = -ENXIO; /* No such CPU */
goto out;
}
c = &cpu_data(cpu);
if (!cpu_has(c, X86_FEATURE_MSR))
ret = -EIO; /* MSR not supported */
out:
unlock_kernel();
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册