William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 1 | #ifndef _LINUX_ERR_H |
| 2 | #define _LINUX_ERR_H |
| 3 | |
| 4 | /* XXX U-BOOT XXX */ |
| 5 | #if 0 |
| 6 | #include <linux/compiler.h> |
| 7 | #else |
Mike Frysinger | 7b15e2b | 2012-04-09 13:39:55 +0000 | [diff] [blame] | 8 | #include <linux/compat.h> |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 9 | #endif |
| 10 | |
| 11 | #include <asm/errno.h> |
| 12 | |
| 13 | |
| 14 | /* |
| 15 | * Kernel pointers have redundant information, so we can use a |
| 16 | * scheme where we can return either an error code or a dentry |
| 17 | * pointer with the same return value. |
| 18 | * |
| 19 | * This should be a per-architecture thing, to allow different |
| 20 | * error and pointer decisions. |
| 21 | */ |
| 22 | #define MAX_ERRNO 4095 |
| 23 | |
| 24 | #ifndef __ASSEMBLY__ |
| 25 | |
| 26 | #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) |
| 27 | |
| 28 | static inline void *ERR_PTR(long error) |
| 29 | { |
| 30 | return (void *) error; |
| 31 | } |
| 32 | |
| 33 | static inline long PTR_ERR(const void *ptr) |
| 34 | { |
| 35 | return (long) ptr; |
| 36 | } |
| 37 | |
| 38 | static inline long IS_ERR(const void *ptr) |
| 39 | { |
| 40 | return IS_ERR_VALUE((unsigned long)ptr); |
| 41 | } |
| 42 | |
| 43 | #endif |
| 44 | |
| 45 | #endif /* _LINUX_ERR_H */ |