Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpu: change cpu_sys_devices from array to per_cpu variable

Change cpu_sys_devices from array to per_cpu variable in drivers/base/cpu.c.

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Vivek Goyal <vgoyal@in.ibm.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mike Travis and committed by
Linus Torvalds
e37d05da bd730967

+5 -5
+5 -5
drivers/base/cpu.c
··· 18 18 }; 19 19 EXPORT_SYMBOL(cpu_sysdev_class); 20 20 21 - static struct sys_device *cpu_sys_devices[NR_CPUS]; 21 + static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); 22 22 23 23 #ifdef CONFIG_HOTPLUG_CPU 24 24 static ssize_t show_online(struct sys_device *dev, char *buf) ··· 68 68 sysdev_remove_file(&cpu->sysdev, &attr_online); 69 69 70 70 sysdev_unregister(&cpu->sysdev); 71 - cpu_sys_devices[logical_cpu] = NULL; 71 + per_cpu(cpu_sys_devices, logical_cpu) = NULL; 72 72 return; 73 73 } 74 74 #else /* ... !CONFIG_HOTPLUG_CPU */ ··· 167 167 if (!error && cpu->hotpluggable) 168 168 register_cpu_control(cpu); 169 169 if (!error) 170 - cpu_sys_devices[num] = &cpu->sysdev; 170 + per_cpu(cpu_sys_devices, num) = &cpu->sysdev; 171 171 if (!error) 172 172 register_cpu_under_node(num, cpu_to_node(num)); 173 173 ··· 180 180 181 181 struct sys_device *get_cpu_sysdev(unsigned cpu) 182 182 { 183 - if (cpu < NR_CPUS) 184 - return cpu_sys_devices[cpu]; 183 + if (cpu < nr_cpu_ids && cpu_possible(cpu)) 184 + return per_cpu(cpu_sys_devices, cpu); 185 185 else 186 186 return NULL; 187 187 }