Merge branch 'msm-fix' of git://codeaurora.org/quic/kernel/davidb/linux-msm into...
[deliverable/linux.git] / arch / sh / oprofile / common.c
CommitLineData
60a51fbe
PM
1/*
2 * arch/sh/oprofile/init.c
3 *
2e4f17d2 4 * Copyright (C) 2003 - 2010 Paul Mundt
60a51fbe
PM
5 *
6 * Based on arch/mips/oprofile/common.c:
7 *
8 * Copyright (C) 2004, 2005 Ralf Baechle
9 * Copyright (C) 2005 MIPS Technologies, Inc.
10 *
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.
14 */
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>
86c8c047 20#include <linux/perf_event.h>
2e4f17d2 21#include <linux/slab.h>
60a51fbe 22#include <asm/processor.h>
60a51fbe 23
40a8b421
DP
24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
25
7c842470 26#ifdef CONFIG_HW_PERF_EVENTS
2e4f17d2
PM
27/*
28 * This will need to be reworked when multiple PMUs are supported.
29 */
30static char *sh_pmu_op_name;
31
86c8c047 32char *op_name_from_perf_id(void)
60a51fbe 33{
2e4f17d2 34 return sh_pmu_op_name;
60a51fbe
PM
35}
36
86c8c047 37int __init oprofile_arch_init(struct oprofile_operations *ops)
60a51fbe 38{
86c8c047 39 ops->backtrace = sh_backtrace;
60a51fbe 40
2e4f17d2
PM
41 if (perf_num_counters() == 0)
42 return -ENODEV;
43
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;
48
86c8c047 49 return oprofile_perf_init(ops);
60a51fbe
PM
50}
51
55205c91 52void oprofile_arch_exit(void)
60a51fbe 53{
86c8c047 54 oprofile_perf_exit();
2e4f17d2 55 kfree(sh_pmu_op_name);
60a51fbe 56}
86c8c047 57#else
60a51fbe
PM
58int __init oprofile_arch_init(struct oprofile_operations *ops)
59{
7c842470 60 ops->backtrace = sh_backtrace;
86c8c047 61 return -ENODEV;
60a51fbe 62}
55205c91 63void oprofile_arch_exit(void) {}
86c8c047 64#endif /* CONFIG_HW_PERF_EVENTS */
This page took 0.215226 seconds and 5 git commands to generate.