Move cpu stuff from arch/i386 into generic code
PATCH 1/1 Move cpu stuff from arch/i386 into generic code
This means that the cpus will appear in driverfs for *all* archs. Also changed it to per-cpu data, and makes cpu.o compiled even if !SMP.
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,20 +93,15 @@ 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 get_cpu () ({ preempt_disable(); smp_processor_id(); })#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 */
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 +45 -1
59 lines not on this page · raw message
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.