blob: c572d250a0c837438bc0a82f173f12d6a7fe4b8a [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#ifndef _LINUX_ERR_H
2#define _LINUX_ERR_H
3
4/* XXX U-BOOT XXX */
5
6#include <linux/compiler.h>
7#include <linux/mtd/compat.h>
8#include <asm/errno.h>
9
10
11/*
12 * Kernel pointers have redundant information, so we can use a
13 * scheme where we can return either an error code or a dentry
14 * pointer with the same return value.
15 *
16 * This should be a per-architecture thing, to allow different
17 * error and pointer decisions.
18 */
19#define MAX_ERRNO 4095
20
21#ifndef __ASSEMBLY__
22
23#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
24
25static inline void *ERR_PTR(long error)
26{
27 return (void *) error;
28}
29
30static inline long PTR_ERR(const void *ptr)
31{
32 return (long) ptr;
33}
34
35static inline long IS_ERR(const void *ptr)
36{
37 return IS_ERR_VALUE((unsigned long)ptr);
38}
39
40#endif
41
42#endif /* _LINUX_ERR_H */