staging: erofs: fix warning Comparison to bool
[linux/fpc-iii.git] / arch / arm64 / kernel / return_address.c
blob53c40196b607264c2bd5e9f7091c6d5d7e1f442a
1 /*
2 * arch/arm64/kernel/return_address.c
4 * Copyright (C) 2013 Linaro Limited
5 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/export.h>
13 #include <linux/ftrace.h>
15 #include <asm/stack_pointer.h>
16 #include <asm/stacktrace.h>
18 struct return_address_data {
19 unsigned int level;
20 void *addr;
23 static int save_return_addr(struct stackframe *frame, void *d)
25 struct return_address_data *data = d;
27 if (!data->level) {
28 data->addr = (void *)frame->pc;
29 return 1;
30 } else {
31 --data->level;
32 return 0;
36 void *return_address(unsigned int level)
38 struct return_address_data data;
39 struct stackframe frame;
41 data.level = level + 2;
42 data.addr = NULL;
44 frame.fp = (unsigned long)__builtin_frame_address(0);
45 frame.pc = (unsigned long)return_address; /* dummy */
46 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
47 frame.graph = 0;
48 #endif
50 walk_stackframe(current, &frame, save_return_addr, &data);
52 if (!data.level)
53 return data.addr;
54 else
55 return NULL;
57 EXPORT_SYMBOL_GPL(return_address);