Commit 7777d006 authored by John Levon's avatar John Levon Committed by Linus Torvalds

[PATCH] bk - fix oprofile for pm driver register

OK, so I screwed up - didn't notice the late_initcall() that was
introduced, which was obviously bogus. This one should build OK for the
module case. I've tested insmod/rmmod alongside a mounted sysfs.

I think the built-in case is OK: oprofile/ is after kernel/ in the link
order. I tested that too.
parent 99686994
...@@ -186,3 +186,9 @@ oprofile_arch_init(struct oprofile_operations **ops) ...@@ -186,3 +186,9 @@ oprofile_arch_init(struct oprofile_operations **ops)
return 0; return 0;
} }
void __exit
oprofile_arch_exit(void)
{
}
...@@ -84,7 +84,7 @@ core-y += arch/i386/kernel/ \ ...@@ -84,7 +84,7 @@ core-y += arch/i386/kernel/ \
arch/i386/$(mcore-y)/ arch/i386/$(mcore-y)/
drivers-$(CONFIG_MATH_EMULATION) += arch/i386/math-emu/ drivers-$(CONFIG_MATH_EMULATION) += arch/i386/math-emu/
drivers-$(CONFIG_PCI) += arch/i386/pci/ drivers-$(CONFIG_PCI) += arch/i386/pci/
# FIXME: is drivers- right ? # must be linked after kernel/
drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/ drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/
CFLAGS += $(mflags-y) CFLAGS += $(mflags-y)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
extern int nmi_init(struct oprofile_operations ** ops); extern int nmi_init(struct oprofile_operations ** ops);
extern void nmi_exit(void);
extern void timer_init(struct oprofile_operations ** ops); extern void timer_init(struct oprofile_operations ** ops);
int __init oprofile_arch_init(struct oprofile_operations ** ops) int __init oprofile_arch_init(struct oprofile_operations ** ops)
...@@ -27,3 +28,11 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -27,3 +28,11 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit(void)
{
#ifdef CONFIG_X86_LOCAL_APIC
nmi_exit();
#endif
}
...@@ -67,15 +67,22 @@ static struct device device_nmi = { ...@@ -67,15 +67,22 @@ static struct device device_nmi = {
}; };
static int __init init_nmi_driverfs(void) static int __init init_driverfs(void)
{ {
driver_register(&nmi_driver); driver_register(&nmi_driver);
return device_register(&device_nmi); return device_register(&device_nmi);
} }
late_initcall(init_nmi_driverfs); static void __exit exit_driverfs(void)
{
device_unregister(&device_nmi);
driver_unregister(&nmi_driver);
}
#else
#define init_driverfs() do { } while (0)
#define exit_driverfs() do { } while (0)
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
...@@ -297,6 +304,10 @@ static int __init ppro_init(void) ...@@ -297,6 +304,10 @@ static int __init ppro_init(void)
#endif /* !CONFIG_X86_64 */ #endif /* !CONFIG_X86_64 */
/* in order to get driverfs right */
static int using_nmi;
int __init nmi_init(struct oprofile_operations ** ops) int __init nmi_init(struct oprofile_operations ** ops)
{ {
__u8 vendor = current_cpu_data.x86_vendor; __u8 vendor = current_cpu_data.x86_vendor;
...@@ -339,7 +350,16 @@ int __init nmi_init(struct oprofile_operations ** ops) ...@@ -339,7 +350,16 @@ int __init nmi_init(struct oprofile_operations ** ops)
return 0; return 0;
} }
init_driverfs();
using_nmi = 1;
*ops = &nmi_ops; *ops = &nmi_ops;
printk(KERN_INFO "oprofile: using NMI interrupt.\n"); printk(KERN_INFO "oprofile: using NMI interrupt.\n");
return 1; return 1;
} }
void __exit nmi_exit(void)
{
if (using_nmi)
exit_driverfs();
}
...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit()
{
}
...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit(void)
{
}
...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit(void)
{
}
...@@ -148,6 +148,7 @@ static int __init oprofile_init(void) ...@@ -148,6 +148,7 @@ static int __init oprofile_init(void)
static void __exit oprofile_exit(void) static void __exit oprofile_exit(void)
{ {
oprofilefs_unregister(); oprofilefs_unregister();
oprofile_arch_exit();
} }
......
...@@ -45,6 +45,11 @@ struct oprofile_operations { ...@@ -45,6 +45,11 @@ struct oprofile_operations {
*/ */
int oprofile_arch_init(struct oprofile_operations ** ops); int oprofile_arch_init(struct oprofile_operations ** ops);
/**
* One-time exit/cleanup for the arch.
*/
void oprofile_arch_exit(void);
/** /**
* Add a sample. This may be called from any context. Pass * Add a sample. This may be called from any context. Pass
* smp_processor_id() as cpu. * smp_processor_id() as cpu.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment