Re: [PATCH] Driver Core patches for 2.6.7

From: Greg KH
Date: Tue Jun 22 2004 - 13:01:50 EST


ChangeSet 1.1722.89.58, 2004/06/08 22:45:12-07:00, greg@xxxxxxxxx

cpuid: fix hotplug cpu remove bug for class device.

Signed-off-by: Greg Kroah-Hartman <greg@xxxxxxxxx>


arch/i386/kernel/cpuid.c | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)


diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
--- a/arch/i386/kernel/cpuid.c Tue Jun 22 09:47:34 2004
+++ b/arch/i386/kernel/cpuid.c Tue Jun 22 09:47:34 2004
@@ -158,35 +158,27 @@
.open = cpuid_open,
};

-static void cpuid_class_simple_device_remove(void)
-{
- int i = 0;
- for_each_online_cpu(i)
- class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
- return;
-}
-
static int cpuid_class_simple_device_add(int i)
{
int err = 0;
struct class_device *class_err;

class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
- if (IS_ERR(class_err)) {
+ if (IS_ERR(class_err))
err = PTR_ERR(class_err);
- }
return err;
}
+
static int __devinit cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;

- switch(action) {
+ switch (action) {
case CPU_ONLINE:
cpuid_class_simple_device_add(cpu);
break;
case CPU_DEAD:
- cpuid_class_simple_device_remove();
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu));
break;
}
return NOTIFY_OK;
@@ -224,7 +216,10 @@
goto out;

out_class:
- cpuid_class_simple_device_remove();
+ i = 0;
+ for_each_online_cpu(i) {
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, i));
+ }
class_simple_destroy(cpuid_class);
out_chrdev:
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
@@ -234,7 +229,10 @@

void __exit cpuid_exit(void)
{
- cpuid_class_simple_device_remove();
+ int cpu = 0;
+
+ for_each_online_cpu(cpu)
+ class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu));
class_simple_destroy(cpuid_class);
unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
unregister_cpu_notifier(&cpuid_class_cpu_notifier);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/