Kobject: change arch/x86/kernel/cpu/mcheck/mce_amd_64.c to use kobject_create_and_add

Make this kobject dynamic and convert it to not use kobject_register,
which is going away.

Cc: Jacob Shin <jacob.shin@amd.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman
2007-12-19 09:23:20 -08:00
parent 3830c62fef
commit a521cf209c

View File

@@ -65,7 +65,7 @@ static struct threshold_block threshold_defaults = {
}; };
struct threshold_bank { struct threshold_bank {
struct kobject kobj; struct kobject *kobj;
struct threshold_block *blocks; struct threshold_block *blocks;
cpumask_t cpus; cpumask_t cpus;
}; };
@@ -433,7 +433,7 @@ static __cpuinit int allocate_threshold_blocks(unsigned int cpu,
per_cpu(threshold_banks, cpu)[bank]->blocks = b; per_cpu(threshold_banks, cpu)[bank]->blocks = b;
kobject_set_name(&b->kobj, "misc%i", block); kobject_set_name(&b->kobj, "misc%i", block);
b->kobj.parent = &per_cpu(threshold_banks, cpu)[bank]->kobj; b->kobj.parent = per_cpu(threshold_banks, cpu)[bank]->kobj;
b->kobj.ktype = &threshold_ktype; b->kobj.ktype = &threshold_ktype;
err = kobject_register(&b->kobj); err = kobject_register(&b->kobj);
if (err) if (err)
@@ -489,7 +489,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
goto out; goto out;
err = sysfs_create_link(&per_cpu(device_mce, cpu).kobj, err = sysfs_create_link(&per_cpu(device_mce, cpu).kobj,
&b->kobj, name); b->kobj, name);
if (err) if (err)
goto out; goto out;
@@ -505,16 +505,15 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
goto out; goto out;
} }
kobject_set_name(&b->kobj, "threshold_bank%i", bank); b->kobj = kobject_create_and_add(name, &per_cpu(device_mce, cpu).kobj);
b->kobj.parent = &per_cpu(device_mce, cpu).kobj; if (!b->kobj)
goto out_free;
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
b->cpus = CPU_MASK_ALL; b->cpus = CPU_MASK_ALL;
#else #else
b->cpus = per_cpu(cpu_core_map, cpu); b->cpus = per_cpu(cpu_core_map, cpu);
#endif #endif
err = kobject_register(&b->kobj);
if (err)
goto out_free;
per_cpu(threshold_banks, cpu)[bank] = b; per_cpu(threshold_banks, cpu)[bank] = b;
@@ -531,7 +530,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
continue; continue;
err = sysfs_create_link(&per_cpu(device_mce, i).kobj, err = sysfs_create_link(&per_cpu(device_mce, i).kobj,
&b->kobj, name); b->kobj, name);
if (err) if (err)
goto out; goto out;
@@ -627,7 +626,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
deallocate_threshold_block(cpu, bank); deallocate_threshold_block(cpu, bank);
free_out: free_out:
kobject_unregister(&b->kobj); kobject_unregister(b->kobj);
kfree(b); kfree(b);
per_cpu(threshold_banks, cpu)[bank] = NULL; per_cpu(threshold_banks, cpu)[bank] = NULL;
} }