Commit bf9ffe26 authored by John Levon's avatar John Levon Committed by Linus Torvalds

[PATCH] OProfile: fix init / exit routine

Ensure that the arch exit routines are always called when needed,
previously we could end up with a nasty crash if using oprofile.timer=1,
or the FS register failed.
parent b043632b
...@@ -131,36 +131,33 @@ extern void timer_init(struct oprofile_operations ** ops); ...@@ -131,36 +131,33 @@ extern void timer_init(struct oprofile_operations ** ops);
static int __init oprofile_init(void) static int __init oprofile_init(void)
{ {
int err = -ENODEV;
if (!timer) {
/* Architecture must fill in the interrupt ops and the /* Architecture must fill in the interrupt ops and the
* logical CPU type, or we can fall back to the timer * logical CPU type, or we can fall back to the timer
* interrupt profiler. * interrupt profiler.
*/ */
err = oprofile_arch_init(&oprofile_ops); int err = oprofile_arch_init(&oprofile_ops);
}
if (err == -ENODEV) { if (err == -ENODEV || timer) {
timer_init(&oprofile_ops); timer_init(&oprofile_ops);
err = 0; err = 0;
} } else if (err) {
if (err)
goto out; goto out;
}
if (!oprofile_ops->cpu_type) { if (!oprofile_ops->cpu_type) {
printk(KERN_ERR "oprofile: cpu_type not set !\n"); printk(KERN_ERR "oprofile: cpu_type not set !\n");
err = -EFAULT; err = -EFAULT;
goto out; } else {
err = oprofilefs_register();
} }
err = oprofilefs_register();
if (err) if (err)
goto out; goto out_exit;
out: out:
return err; return err;
out_exit:
oprofile_arch_exit();
goto out;
} }
......
...@@ -40,7 +40,9 @@ struct oprofile_operations { ...@@ -40,7 +40,9 @@ struct oprofile_operations {
/** /**
* One-time initialisation. *ops must be set to a filled-in * One-time initialisation. *ops must be set to a filled-in
* operations structure. * operations structure. This is called even in timer interrupt
* mode.
*
* Return 0 on success. * Return 0 on success.
*/ */
int oprofile_arch_init(struct oprofile_operations ** ops); int oprofile_arch_init(struct oprofile_operations ** ops);
......
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