OMAP: DSS2: fix irq-stats compilation
[linux/fpc-iii.git] / arch / sh / kernel / return_address.c
blobdf3ab5811074f0bfcada56897092f9eeaed937e1
1 /*
2 * arch/sh/kernel/return_address.c
4 * Copyright (C) 2009 Matt Fleming
5 * Copyright (C) 2009 Paul Mundt
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
11 #include <linux/kernel.h>
12 #include <asm/dwarf.h>
14 #ifdef CONFIG_DWARF_UNWINDER
16 void *return_address(unsigned int depth)
18 struct dwarf_frame *frame;
19 unsigned long ra;
20 int i;
22 for (i = 0, frame = NULL, ra = 0; i <= depth; i++) {
23 struct dwarf_frame *tmp;
25 tmp = dwarf_unwind_stack(ra, frame);
27 if (frame)
28 dwarf_free_frame(frame);
30 frame = tmp;
32 if (!frame || !frame->return_addr)
33 break;
35 ra = frame->return_addr;
38 /* Failed to unwind the stack to the specified depth. */
39 WARN_ON(i != depth + 1);
41 if (frame)
42 dwarf_free_frame(frame);
44 return (void *)ra;
47 #else
49 void *return_address(unsigned int depth)
51 return NULL;
54 #endif