Commit 07accdc1 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Driver core: convert cpuid code to use struct device

Converts from using struct "class_device" to "struct device" making
everything show up properly in /sys/devices/ with symlinks from the
/sys/class directory.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a271aaf1
...@@ -156,14 +156,14 @@ static struct file_operations cpuid_fops = { ...@@ -156,14 +156,14 @@ static struct file_operations cpuid_fops = {
.open = cpuid_open, .open = cpuid_open,
}; };
static int cpuid_class_device_create(int i) static int cpuid_device_create(int i)
{ {
int err = 0; int err = 0;
struct class_device *class_err; struct device *dev;
class_err = class_device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i); dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), "cpu%d",i);
if (IS_ERR(class_err)) if (IS_ERR(dev))
err = PTR_ERR(class_err); err = PTR_ERR(dev);
return err; return err;
} }
...@@ -174,10 +174,10 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long ac ...@@ -174,10 +174,10 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long ac
switch (action) { switch (action) {
case CPU_ONLINE: case CPU_ONLINE:
cpuid_class_device_create(cpu); cpuid_device_create(cpu);
break; break;
case CPU_DEAD: case CPU_DEAD:
class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
break; break;
} }
return NOTIFY_OK; return NOTIFY_OK;
...@@ -206,7 +206,7 @@ static int __init cpuid_init(void) ...@@ -206,7 +206,7 @@ static int __init cpuid_init(void)
goto out_chrdev; goto out_chrdev;
} }
for_each_online_cpu(i) { for_each_online_cpu(i) {
err = cpuid_class_device_create(i); err = cpuid_device_create(i);
if (err != 0) if (err != 0)
goto out_class; goto out_class;
} }
...@@ -218,7 +218,7 @@ static int __init cpuid_init(void) ...@@ -218,7 +218,7 @@ static int __init cpuid_init(void)
out_class: out_class:
i = 0; i = 0;
for_each_online_cpu(i) { for_each_online_cpu(i) {
class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i)); device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i));
} }
class_destroy(cpuid_class); class_destroy(cpuid_class);
out_chrdev: out_chrdev:
...@@ -232,7 +232,7 @@ static void __exit cpuid_exit(void) ...@@ -232,7 +232,7 @@ static void __exit cpuid_exit(void)
int cpu = 0; int cpu = 0;
for_each_online_cpu(cpu) for_each_online_cpu(cpu)
class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
class_destroy(cpuid_class); class_destroy(cpuid_class);
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); unregister_hotcpu_notifier(&cpuid_class_cpu_notifier);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment