arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / arm / kernel / return_address.c
blob7b42ac010fdfd450be403a1ebaed98521a23b4c2
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * arch/arm/kernel/return_address.c
5 * Copyright (C) 2009 Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
6 * for Pengutronix
7 */
8 #include <linux/export.h>
9 #include <linux/ftrace.h>
10 #include <linux/sched.h>
12 #include <asm/stacktrace.h>
14 struct return_address_data {
15 unsigned int level;
16 void *addr;
19 static int save_return_addr(struct stackframe *frame, void *d)
21 struct return_address_data *data = d;
23 if (!data->level) {
24 data->addr = (void *)frame->pc;
26 return 1;
27 } else {
28 --data->level;
29 return 0;
33 void *return_address(unsigned int level)
35 struct return_address_data data;
36 struct stackframe frame;
38 data.level = level + 2;
39 data.addr = NULL;
41 frame.fp = (unsigned long)__builtin_frame_address(0);
42 frame.sp = current_stack_pointer;
43 frame.lr = (unsigned long)__builtin_return_address(0);
44 frame.pc = (unsigned long)return_address;
46 walk_stackframe(&frame, save_return_addr, &data);
48 if (!data.level)
49 return data.addr;
50 else
51 return NULL;
54 EXPORT_SYMBOL_GPL(return_address);