OMAP3: GPIO: Enable debounce clock only when debounce is enabled v3.
[linux-ginger.git] / arch / arm / oprofile / backtrace.c
blobf5ebf30151fa9f22b7311e59ed20b0773d8dda21
1 /*
2 * Arm specific backtracing code for oprofile
4 * Copyright 2005 Openedhand Ltd.
6 * Author: Richard Purdie <rpurdie@openedhand.com>
8 * Based on i386 oprofile backtrace code by John Levon, David Smith
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
16 #include <linux/oprofile.h>
17 #include <linux/sched.h>
18 #include <linux/mm.h>
19 #include <asm/ptrace.h>
20 #include <asm/uaccess.h>
22 #include "../kernel/stacktrace.h"
24 static int report_trace(struct stackframe *frame, void *d)
26 unsigned int *depth = d;
28 if (*depth) {
29 oprofile_add_trace(frame->lr);
30 (*depth)--;
33 return *depth == 0;
37 * The registers we're interested in are at the end of the variable
38 * length saved register structure. The fp points at the end of this
39 * structure so the address of this struct is:
40 * (struct frame_tail *)(xxx->fp)-1
42 struct frame_tail {
43 struct frame_tail *fp;
44 unsigned long sp;
45 unsigned long lr;
46 } __attribute__((packed));
48 static struct frame_tail* user_backtrace(struct frame_tail *tail)
50 struct frame_tail buftail[2];
52 /* Also check accessibility of one struct frame_tail beyond */
53 if (!access_ok(VERIFY_READ, tail, sizeof(buftail)))
54 return NULL;
55 if (__copy_from_user_inatomic(buftail, tail, sizeof(buftail)))
56 return NULL;
58 oprofile_add_trace(buftail[0].lr);
60 /* frame pointers should strictly progress back up the stack
61 * (towards higher addresses) */
62 if (tail >= buftail[0].fp)
63 return NULL;
65 return buftail[0].fp-1;
68 void arm_backtrace(struct pt_regs * const regs, unsigned int depth)
70 struct frame_tail *tail = ((struct frame_tail *) regs->ARM_fp) - 1;
72 if (!user_mode(regs)) {
73 unsigned long base = ((unsigned long)regs) & ~(THREAD_SIZE - 1);
74 walk_stackframe(regs->ARM_fp, base, base + THREAD_SIZE,
75 report_trace, &depth);
76 return;
79 while (depth-- && tail && !((unsigned long) tail & 3))
80 tail = user_backtrace(tail);