summaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/oprof.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2011-12-16 07:02:34 +0100
committerOlof Johansson <olof@lixom.net>2011-12-16 07:02:34 +0100
commit02735a29d8ce882ec698803f064e17888874780c (patch)
tree6a4afa3bc8b6d4334df24910a56f77adf126b0c7 /drivers/oprofile/oprof.c
parentMerge branches 'at91/gpio', 'at91/ioremap', 'drivers/macb-gem-cleanup' and 'm... (diff)
parentMerge branch 'for-arnd-3.3-defconfig' of git://github.com/at91linux/linux-at9... (diff)
downloadlinux-02735a29d8ce882ec698803f064e17888874780c.tar.xz
linux-02735a29d8ce882ec698803f064e17888874780c.zip
Merge branch 'at91/defconfig' into next/cleanup
Diffstat (limited to 'drivers/oprofile/oprof.c')
-rw-r--r--drivers/oprofile/oprof.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index dccd8636095c..f8c752e408a6 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -239,26 +239,45 @@ int oprofile_set_ulong(unsigned long *addr, unsigned long val)
return err;
}
+static int timer_mode;
+
static int __init oprofile_init(void)
{
int err;
+ /* always init architecture to setup backtrace support */
err = oprofile_arch_init(&oprofile_ops);
- if (err < 0 || timer) {
- printk(KERN_INFO "oprofile: using timer interrupt.\n");
+
+ timer_mode = err || timer; /* fall back to timer mode on errors */
+ if (timer_mode) {
+ if (!err)
+ oprofile_arch_exit();
err = oprofile_timer_init(&oprofile_ops);
if (err)
return err;
}
- return oprofilefs_register();
+
+ err = oprofilefs_register();
+ if (!err)
+ return 0;
+
+ /* failed */
+ if (timer_mode)
+ oprofile_timer_exit();
+ else
+ oprofile_arch_exit();
+
+ return err;
}
static void __exit oprofile_exit(void)
{
- oprofile_timer_exit();
oprofilefs_unregister();
- oprofile_arch_exit();
+ if (timer_mode)
+ oprofile_timer_exit();
+ else
+ oprofile_arch_exit();
}