Skip to content

Commit

Permalink
Driver core: convert cpuid code to use struct device
Browse files Browse the repository at this point in the history
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: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Dec 1, 2006
1 parent a271aaf commit 07accdc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions arch/i386/kernel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ static struct file_operations cpuid_fops = {
.open = cpuid_open,
};

static int cpuid_class_device_create(int i)
static int cpuid_device_create(int i)
{
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);
if (IS_ERR(class_err))
err = PTR_ERR(class_err);
dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), "cpu%d",i);
if (IS_ERR(dev))
err = PTR_ERR(dev);
return err;
}

Expand All @@ -174,10 +174,10 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long ac

switch (action) {
case CPU_ONLINE:
cpuid_class_device_create(cpu);
cpuid_device_create(cpu);
break;
case CPU_DEAD:
class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
break;
}
return NOTIFY_OK;
Expand Down Expand Up @@ -206,7 +206,7 @@ static int __init cpuid_init(void)
goto out_chrdev;
}
for_each_online_cpu(i) {
err = cpuid_class_device_create(i);
err = cpuid_device_create(i);
if (err != 0)
goto out_class;
}
Expand All @@ -218,7 +218,7 @@ static int __init cpuid_init(void)
out_class:
i = 0;
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);
out_chrdev:
Expand All @@ -232,7 +232,7 @@ static void __exit cpuid_exit(void)
int cpu = 0;

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);
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
unregister_hotcpu_notifier(&cpuid_class_cpu_notifier);
Expand Down

0 comments on commit 07accdc

Please sign in to comment.