Merge branch 'rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[linux/fpc-iii.git] / arch / sh / oprofile / common.c
blobb4c2d2b946ddc084bfe48b2d58128d47e2f724aa
1 /*
2 * arch/sh/oprofile/init.c
4 * Copyright (C) 2003 - 2010 Paul Mundt
6 * Based on arch/mips/oprofile/common.c:
8 * Copyright (C) 2004, 2005 Ralf Baechle
9 * Copyright (C) 2005 MIPS Technologies, Inc.
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
15 #include <linux/kernel.h>
16 #include <linux/oprofile.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/smp.h>
20 #include <linux/perf_event.h>
21 #include <linux/slab.h>
22 #include <asm/processor.h>
24 extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
26 #ifdef CONFIG_HW_PERF_EVENTS
28 * This will need to be reworked when multiple PMUs are supported.
30 static char *sh_pmu_op_name;
32 char *op_name_from_perf_id(void)
34 return sh_pmu_op_name;
37 int __init oprofile_arch_init(struct oprofile_operations *ops)
39 ops->backtrace = sh_backtrace;
41 if (perf_num_counters() == 0)
42 return -ENODEV;
44 sh_pmu_op_name = kasprintf(GFP_KERNEL, "%s/%s",
45 UTS_MACHINE, perf_pmu_name());
46 if (unlikely(!sh_pmu_op_name))
47 return -ENOMEM;
49 return oprofile_perf_init(ops);
52 void __exit oprofile_arch_exit(void)
54 oprofile_perf_exit();
55 kfree(sh_pmu_op_name);
57 #else
58 int __init oprofile_arch_init(struct oprofile_operations *ops)
60 ops->backtrace = sh_backtrace;
61 return -ENODEV;
63 void __exit oprofile_arch_exit(void) {}
64 #endif /* CONFIG_HW_PERF_EVENTS */