Mark Rutland | 5b7e8f7 | 2016-11-03 20:23:13 +0000 | [diff] [blame] | 1 | #ifndef __ASM_CURRENT_H |
| 2 | #define __ASM_CURRENT_H |
| 3 | |
| 4 | #include <linux/compiler.h> |
| 5 | |
| 6 | #include <asm/sysreg.h> |
| 7 | |
| 8 | #ifndef __ASSEMBLY__ |
| 9 | |
| 10 | struct task_struct; |
| 11 | |
Mark Rutland | 8c01d00 | 2017-01-03 18:27:01 +0000 | [diff] [blame] | 12 | /* |
| 13 | * We don't use read_sysreg() as we want the compiler to cache the value where |
| 14 | * possible. |
| 15 | */ |
Mark Rutland | 5b7e8f7 | 2016-11-03 20:23:13 +0000 | [diff] [blame] | 16 | static __always_inline struct task_struct *get_current(void) |
| 17 | { |
Mark Rutland | 8c01d00 | 2017-01-03 18:27:01 +0000 | [diff] [blame] | 18 | unsigned long sp_el0; |
| 19 | |
| 20 | asm ("mrs %0, sp_el0" : "=r" (sp_el0)); |
| 21 | |
| 22 | return (struct task_struct *)sp_el0; |
Mark Rutland | 5b7e8f7 | 2016-11-03 20:23:13 +0000 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | #define current get_current() |
| 26 | |
| 27 | #endif /* __ASSEMBLY__ */ |
| 28 | |
| 29 | #endif /* __ASM_CURRENT_H */ |
| 30 | |