blob: 96c0c72baa6b4364a552a7521e9a3fe7620f171b [file] [log] [blame]
William Juulcfa460a2007-10-31 13:53:06 +01001#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 Frysinger7b15e2b2012-04-09 13:39:55 +00008#include <linux/compat.h>
William Juulcfa460a2007-10-31 13:53:06 +01009#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
28static inline void *ERR_PTR(long error)
29{
30 return (void *) error;
31}
32
33static inline long PTR_ERR(const void *ptr)
34{
35 return (long) ptr;
36}
37
38static 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 */