Move driverfs cpu stuff to kernel/cpu.c
PATCH 1/1 Move driverfs cpu stuff to kernel/cpu.c
Applies against 2.5.44 *and* 2.5.44-mm4.
Name: Put cpus in driverfs for all architectures
Author: Rusty Russell
Status: Trivial
D: Moves registering of cpus from arch/i386/kernel/cpu/common.c into
D: kernel/cpu.c, makes it use per-cpu variables, and makes
D: kernel/cpu.c compiled even on non-SMP (as the entry must exist even
D: for UP). This allows some UP stubs to be removed from smp.h into
D: kernel/cpu.c, too.
arch/i386/kernel/cpu/common.c +0 -34
@@ -507,37 +507,3 @@ void __init cpu_init (void) current->used_math =0 ;stts (); } - -/* -* Bulk registration of the cpu devices with the system. -* Some of this stuff could possibly be moved into a shared -* location.. -* Also, these devices should be integrated with other CPU data.. -*/ - -static struct cpu cpu_devices[NR_CPUS ]; - -static struct device_driver cpu_driver = { - .name ="cpu" , - .bus = &system_bus_type, - .devclass = &cpu_devclass, -}; - -static int __init register_cpus (void ) -{ -int i; - -driver_register (&cpu_driver); - -for (i =0 ; i <NR_CPUS ; i++) { -struct sys_device * sysdev = &cpu_devices[i].sysdev; - sysdev->name ="cpu" ; - sysdev->id = i; - sysdev->dev.driver = &cpu_driver; -if (cpu_possible (i)) -sys_device_register (sysdev); - } -return 0 ; -} - -subsys_initcall (register_cpus);
include/linux/cpu.h +5 -0
@@ -19,6 +19,7 @@*/ #include <linux/device.h> +#include <linux/percpu.h> extern struct device_class cpu_devclass;
@@ -26,3 +27,7 @@ struct cpu {struct sys_device sysdev; }; +DECLARE_PER_CPU(struct cpu, cpu_devices); + +/* Bring a CPU up */ +int cpu_up (unsigned int cpu);
include/linux/smp.h +5 -18
@@ -70,14 +70,6 @@ extern volatile int smp_msg_id;*/ #define MSG_RESCHEDULE 0x0003/* Reschedule request from master CPU*/ #define MSG_CALL_FUNCTION 0x0004/* Call function on all other CPUs */ - -struct notifier_block ; - -/* Need to know about CPUs going up/down? */ -extern int register_cpu_notifier (struct notifier_block *nb); -extern void unregister_cpu_notifier (struct notifier_block *nb); - -int cpu_up (unsigned int cpu);#else /* !SMP */ /*
@@ -101,16 +93,6 @@ static inline void smp_send_reschedule_a#define first_possible_cpu () 0#define next_possible_cpu (cpu) NR_CPUS -struct notifier_block ; - -/* Need to know about CPUs going up/down? */ -static inline int register_cpu_notifier (struct notifier_block *nb) -{ -return 0 ; -} -static inline void unregister_cpu_notifier (struct notifier_block *nb) -{ -}#endif /* !SMP */ #define for_each_possible_cpu (var) \
@@ -127,4 +109,9 @@ static inline void unregister_cpu_notifi#define put_cpu () preempt_enable()#define put_cpu_no_resched () preempt_enable_no_resched() +/* Need to know about CPUs going up/down? */ +struct notifier_block ; +extern int register_cpu_notifier (struct notifier_block *nb); +extern void unregister_cpu_notifier (struct notifier_block *nb); +#endif /* __LINUX_SMP_H */
init/main.c +1 -0
@@ -33,6 +33,7 @@#include <linux/workqueue.h> #include <linux/profile.h> #include <linux/rcupdate.h> +#include <linux/cpu.h> #include <asm/io.h> #include <asm/bugs.h>
kernel/Makefile +2 -3
@@ -4,16 +4,15 @@ export-objs = signal.o sys.o kmod.o workqueue.o ksyms.o pm.o exec_domain.o \ printk.o platform.o suspend.o dma.o module.o cpufreq.o \ - profile.o rcupdate.o + profile.o rcupdate.o cpu.o obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ module.o exit.o itimer.o time.o softirq.o resource.o \ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o futex.o platform.o pid.o \ - rcupdate.o + rcupdate.o cpu.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o -obj-$(CONFIG_SMP) += cpu.o obj-$(CONFIG_UID16) += uid16.o obj-$(CONFIG_MODULES) += ksyms.o obj-$(CONFIG_KALLSYMS) += kallsyms.o
kernel/cpu.c +47 -1
66 lines not on this page · raw message
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.