Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Christoph Hellwig | 7a8998c | 2019-06-13 09:08:59 +0200 | [diff] [blame] | 2 | #ifndef _ASM_GENERIC_FLAT_H |
| 3 | #define _ASM_GENERIC_FLAT_H |
Greg Ungerer | acc46c0 | 2006-09-14 00:28:26 +1000 | [diff] [blame] | 4 | |
Al Viro | 468138d | 2017-05-02 19:52:17 -0400 | [diff] [blame] | 5 | #include <linux/uaccess.h> |
| 6 | |
Al Viro | 468138d | 2017-05-02 19:52:17 -0400 | [diff] [blame] | 7 | static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, |
Christoph Hellwig | 6843d8a | 2019-06-13 09:09:00 +0200 | [diff] [blame] | 8 | u32 *addr) |
Al Viro | 468138d | 2017-05-02 19:52:17 -0400 | [diff] [blame] | 9 | { |
| 10 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
| 11 | return copy_from_user(addr, rp, 4) ? -EFAULT : 0; |
| 12 | #else |
| 13 | return get_user(*addr, rp); |
| 14 | #endif |
| 15 | } |
| 16 | |
| 17 | static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) |
| 18 | { |
| 19 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
| 20 | return copy_to_user(rp, &addr, 4) ? -EFAULT : 0; |
| 21 | #else |
| 22 | return put_user(addr, rp); |
| 23 | #endif |
| 24 | } |
| 25 | |
Christoph Hellwig | 7a8998c | 2019-06-13 09:08:59 +0200 | [diff] [blame] | 26 | #endif /* _ASM_GENERIC_FLAT_H */ |