[RFC PATCH 01/13] linux err: Synchronize with Linux 5.10
Sean Anderson
seanga2 at gmail.com
Fri Feb 5 05:39:11 CET 2021
This synchronizes linux/err.h with Linux 5.10. Notably, this adds
PTR_ERR_OR_ZERO.
Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---
include/linux/err.h | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/include/linux/err.h b/include/linux/err.h
index 5ede82432d..06a80f9f29 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_ERR_H
#define _LINUX_ERR_H
@@ -9,7 +10,7 @@
/*
* Kernel pointers have redundant information, so we can use a
- * scheme where we can return either an error code or a dentry
+ * scheme where we can return either an error code or a normal
* pointer with the same return value.
*
* This should be a per-architecture thing, to allow different
@@ -21,24 +22,24 @@
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
-static inline void *ERR_PTR(long error)
+static inline void * __must_check ERR_PTR(long error)
{
return (void *)(CONFIG_ERR_PTR_OFFSET + error);
}
-static inline long PTR_ERR(const void *ptr)
+static inline long __must_check PTR_ERR(__force const void *ptr)
{
return ((long)ptr - CONFIG_ERR_PTR_OFFSET);
}
-static inline long IS_ERR(const void *ptr)
+static inline bool __must_check IS_ERR(__force const void *ptr)
{
return IS_ERR_VALUE((unsigned long)PTR_ERR(ptr));
}
-static inline bool IS_ERR_OR_NULL(const void *ptr)
+static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
{
- return !ptr || IS_ERR_VALUE((unsigned long)PTR_ERR(ptr));
+ return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
}
/**
@@ -54,6 +55,14 @@ static inline void * __must_check ERR_CAST(__force const void *ptr)
return (void *) ptr;
}
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+ if (IS_ERR(ptr))
+ return PTR_ERR(ptr);
+ else
+ return 0;
+}
+
#endif
#endif /* _LINUX_ERR_H */
--
2.29.2
More information about the U-Boot
mailing list