From 5a178a5e1e83abed4c9796e501845805e8d1d1f4 Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Sun, 30 Oct 2005 14:59:49 -0800 Subject: [PATCH] --- yaml --- r: 11775 b: refs/heads/master c: ad74557a49d1dea428fb0ad60e75a5aa37610e1d h: refs/heads/master i: 11773: 908a02a3c998059646d2ce01e7abe4e382248148 11771: d456ae8cfc61ac76f886fafd761ea4280ddbb889 11767: 57fff131348d19732c0b1c2de410192b79078270 11759: d77fb2d61537857b950157212600b8c7ebf5d399 11743: 4a922cf511d24b4fd6bc9b3a812c1c0d687c3654 11711: f9d255fa7de98a245d9b13cf7299299589ee1244 11647: c8c27044708343057f88aa9e9eb79f20c80df0f6 11519: c5cb1be122448aba9a51583dc5fcbe16ccb18884 11263: 64a15b2df74da9519cb3950092a55a55e7eed0d6 v: v3 --- [refs] | 2 +- trunk/drivers/base/cpu.c | 16 ++++++++++++++-- trunk/include/linux/cpu.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 0684a6d278ee..2ebdb74abaf1 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5d35704028d09a183448daceab5dcb94f21a3645 +refs/heads/master: ad74557a49d1dea428fb0ad60e75a5aa37610e1d diff --git a/trunk/drivers/base/cpu.c b/trunk/drivers/base/cpu.c index 081c927b1ed8..a95844790f7b 100644 --- a/trunk/drivers/base/cpu.c +++ b/trunk/drivers/base/cpu.c @@ -16,6 +16,8 @@ struct sysdev_class cpu_sysdev_class = { }; EXPORT_SYMBOL(cpu_sysdev_class); +static struct sys_device *cpu_sys_devices[NR_CPUS]; + #ifdef CONFIG_HOTPLUG_CPU int __attribute__((weak)) smp_prepare_cpu (int cpu) { @@ -64,6 +66,7 @@ static void __devinit register_cpu_control(struct cpu *cpu) } void unregister_cpu(struct cpu *cpu, struct node *root) { + int logical_cpu = cpu->sysdev.id; if (root) sysfs_remove_link(&root->sysdev.kobj, @@ -71,7 +74,7 @@ void unregister_cpu(struct cpu *cpu, struct node *root) sysdev_remove_file(&cpu->sysdev, &attr_online); sysdev_unregister(&cpu->sysdev); - + cpu_sys_devices[logical_cpu] = NULL; return; } #else /* ... !CONFIG_HOTPLUG_CPU */ @@ -103,10 +106,19 @@ int __devinit register_cpu(struct cpu *cpu, int num, struct node *root) kobject_name(&cpu->sysdev.kobj)); if (!error && !cpu->no_control) register_cpu_control(cpu); + if (!error) + cpu_sys_devices[num] = &cpu->sysdev; return error; } - +struct sys_device *get_cpu_sysdev(int cpu) +{ + if (cpu < NR_CPUS) + return cpu_sys_devices[cpu]; + else + return NULL; +} +EXPORT_SYMBOL_GPL(get_cpu_sysdev); int __init cpu_dev_init(void) { diff --git a/trunk/include/linux/cpu.h b/trunk/include/linux/cpu.h index 86980c68234a..1f7b2c097503 100644 --- a/trunk/include/linux/cpu.h +++ b/trunk/include/linux/cpu.h @@ -32,6 +32,7 @@ struct cpu { }; extern int register_cpu(struct cpu *, int, struct node *); +extern struct sys_device *get_cpu_sysdev(int cpu); #ifdef CONFIG_HOTPLUG_CPU extern void unregister_cpu(struct cpu *, struct node *); #endif