X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=drivers%2Fbase%2Fcpu.c;h=e38dfed41d80b8e6dff45379ee1fdfb8e8d3c750;hb=29e92f483603d97dd1d2bafcb32101287dfac4ad;hp=2c76afff3b15060e723fcec52569e450a3c46265;hpb=ec965350bb98bd291eb34f6ecddfdcfc36da1e6e;p=cascardo%2Flinux.git diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 2c76afff3b15..e38dfed41d80 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -18,7 +18,7 @@ struct sysdev_class cpu_sysdev_class = { }; EXPORT_SYMBOL(cpu_sysdev_class); -static struct sys_device *cpu_sys_devices[NR_CPUS]; +static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); #ifdef CONFIG_HOTPLUG_CPU static ssize_t show_online(struct sys_device *dev, char *buf) @@ -28,7 +28,7 @@ static ssize_t show_online(struct sys_device *dev, char *buf) return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); } -static ssize_t store_online(struct sys_device *dev, const char *buf, +static ssize_t __ref store_online(struct sys_device *dev, const char *buf, size_t count) { struct cpu *cpu = container_of(dev, struct cpu, sysdev); @@ -55,7 +55,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf, } static SYSDEV_ATTR(online, 0644, show_online, store_online); -static void __devinit register_cpu_control(struct cpu *cpu) +static void __cpuinit register_cpu_control(struct cpu *cpu) { sysdev_create_file(&cpu->sysdev, &attr_online); } @@ -68,7 +68,7 @@ void unregister_cpu(struct cpu *cpu) sysdev_remove_file(&cpu->sysdev, &attr_online); sysdev_unregister(&cpu->sysdev); - cpu_sys_devices[logical_cpu] = NULL; + per_cpu(cpu_sys_devices, logical_cpu) = NULL; return; } #else /* ... !CONFIG_HOTPLUG_CPU */ @@ -167,7 +167,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) if (!error && cpu->hotpluggable) register_cpu_control(cpu); if (!error) - cpu_sys_devices[num] = &cpu->sysdev; + per_cpu(cpu_sys_devices, num) = &cpu->sysdev; if (!error) register_cpu_under_node(num, cpu_to_node(num)); @@ -180,8 +180,8 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) struct sys_device *get_cpu_sysdev(unsigned cpu) { - if (cpu < NR_CPUS) - return cpu_sys_devices[cpu]; + if (cpu < nr_cpu_ids && cpu_possible(cpu)) + return per_cpu(cpu_sys_devices, cpu); else return NULL; }