staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / arch / arm / kernel / return_address.c
blobb0d2f1fe891d129f15db6c16bf62bfbdfc8ed4a8
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>
11 #if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
12 #include <linux/sched.h>
14 #include <asm/stacktrace.h>
16 struct return_address_data {
17 unsigned int level;
18 void *addr;
21 static int save_return_addr(struct stackframe *frame, void *d)
23 struct return_address_data *data = d;
25 if (!data->level) {
26 data->addr = (void *)frame->pc;
28 return 1;
29 } else {
30 --data->level;
31 return 0;
35 void *return_address(unsigned int level)
37 struct return_address_data data;
38 struct stackframe frame;
40 data.level = level + 2;
41 data.addr = NULL;
43 frame.fp = (unsigned long)__builtin_frame_address(0);
44 frame.sp = current_stack_pointer;
45 frame.lr = (unsigned long)__builtin_return_address(0);
46 frame.pc = (unsigned long)return_address;
48 walk_stackframe(&frame, save_return_addr, &data);
50 if (!data.level)
51 return data.addr;
52 else
53 return NULL;
56 #endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) */
58 EXPORT_SYMBOL_GPL(return_address);