diff options
Diffstat (limited to 'arch/x86/kernel/cpuid.c')
| -rw-r--r-- | arch/x86/kernel/cpuid.c | 25 | 
1 files changed, 14 insertions, 11 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 1b7b31ab7d8..3225ae6c518 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -33,7 +33,6 @@  #include <linux/init.h>  #include <linux/poll.h>  #include <linux/smp.h> -#include <linux/smp_lock.h>  #include <linux/major.h>  #include <linux/fs.h>  #include <linux/device.h> @@ -44,7 +43,6 @@  #include <asm/processor.h>  #include <asm/msr.h> -#include <asm/system.h>  static struct class *cpuid_class; @@ -87,7 +85,7 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,  {  	char __user *tmp = buf;  	struct cpuid_regs cmd; -	int cpu = iminor(file->f_path.dentry->d_inode); +	int cpu = iminor(file_inode(file));  	u64 pos = *ppos;  	ssize_t bytes = 0;  	int err = 0; @@ -118,7 +116,7 @@ static int cpuid_open(struct inode *inode, struct file *file)  	unsigned int cpu;  	struct cpuinfo_x86 *c; -	cpu = iminor(file->f_path.dentry->d_inode); +	cpu = iminor(file_inode(file));  	if (cpu >= nr_cpu_ids || !cpu_online(cpu))  		return -ENXIO;	/* No such CPU */ @@ -139,7 +137,7 @@ static const struct file_operations cpuid_fops = {  	.open = cpuid_open,  }; -static __cpuinit int cpuid_device_create(int cpu) +static int cpuid_device_create(int cpu)  {  	struct device *dev; @@ -153,9 +151,8 @@ static void cpuid_device_destroy(int cpu)  	device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));  } -static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, -					      unsigned long action, -					      void *hcpu) +static int cpuid_class_cpu_callback(struct notifier_block *nfb, +				    unsigned long action, void *hcpu)  {  	unsigned int cpu = (unsigned long)hcpu;  	int err = 0; @@ -178,7 +175,7 @@ static struct notifier_block __refdata cpuid_class_cpu_notifier =  	.notifier_call = cpuid_class_cpu_callback,  }; -static char *cpuid_devnode(struct device *dev, mode_t *mode) +static char *cpuid_devnode(struct device *dev, umode_t *mode)  {  	return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt));  } @@ -201,12 +198,15 @@ static int __init cpuid_init(void)  		goto out_chrdev;  	}  	cpuid_class->devnode = cpuid_devnode; + +	cpu_notifier_register_begin();  	for_each_online_cpu(i) {  		err = cpuid_device_create(i);  		if (err != 0)  			goto out_class;  	} -	register_hotcpu_notifier(&cpuid_class_cpu_notifier); +	__register_hotcpu_notifier(&cpuid_class_cpu_notifier); +	cpu_notifier_register_done();  	err = 0;  	goto out; @@ -216,6 +216,7 @@ out_class:  	for_each_online_cpu(i) {  		cpuid_device_destroy(i);  	} +	cpu_notifier_register_done();  	class_destroy(cpuid_class);  out_chrdev:  	__unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid"); @@ -227,11 +228,13 @@ static void __exit cpuid_exit(void)  {  	int cpu = 0; +	cpu_notifier_register_begin();  	for_each_online_cpu(cpu)  		cpuid_device_destroy(cpu);  	class_destroy(cpuid_class);  	__unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid"); -	unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); +	__unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); +	cpu_notifier_register_done();  }  module_init(cpuid_init);  | 
