28 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/errno.h>
32 #include <linux/fcntl.h>
34 #include <linux/poll.h>
38 #include <linux/device.h>
44 #include <asm/processor.h>
47 static struct class *cpuid_class;
53 static void cpuid_smp_cpuid(
void *cmd_block)
57 cpuid_count(cmd->
eax, cmd->
ecx,
61 static loff_t cpuid_seek(
struct file *
file, loff_t
offset,
int orig)
83 static ssize_t cpuid_read(
struct file *file,
char __user *
buf,
84 size_t count, loff_t *ppos)
88 int cpu = iminor(file->
f_path.dentry->d_inode);
96 for (;
count; count -= 16) {
111 return bytes ? bytes :
err;
114 static int cpuid_open(
struct inode *inode,
struct file *file)
119 cpu = iminor(file->
f_path.dentry->d_inode);
135 .llseek = cpuid_seek,
140 static __cpuinit int cpuid_device_create(
int cpu)
146 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
149 static void cpuid_device_destroy(
int cpu)
158 unsigned int cpu = (
unsigned long)hcpu;
163 err = cpuid_device_create(cpu);
168 cpuid_device_destroy(cpu);
171 return notifier_from_errno(err);
176 .notifier_call = cpuid_class_cpu_callback,
184 static int __init cpuid_init(
void)
190 "cpu/cpuid", &cpuid_fops)) {
197 if (IS_ERR(cpuid_class)) {
198 err = PTR_ERR(cpuid_class);
201 cpuid_class->
devnode = cpuid_devnode;
204 err = cpuid_device_create(i);
217 cpuid_device_destroy(i);
227 static void __exit cpuid_exit(
void)
233 cpuid_device_destroy(cpu);