From: Uwe Kleine-König Date: Tue, 22 Mar 2011 23:34:05 +0000 (-0700) Subject: include/linux/err.h: add a function to cast error-pointers to a return value X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fa9ee9c4b9885dfdf8eccac19b8b4fc8a7c53288;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git include/linux/err.h: add a function to cast error-pointers to a return value PTR_RET() can be used if you have an error-pointer and are only interested in the eventual error value, but not the pointer. Yields the usual 0 for no error, -ESOMETHING otherwise. Signed-off-by: Uwe Kleine-König Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/err.h b/include/linux/err.h index 448afc12c78a..f2edce25a76b 100644 --- a/include/linux/err.h +++ b/include/linux/err.h @@ -52,6 +52,14 @@ static inline void * __must_check ERR_CAST(const void *ptr) return (void *) ptr; } +static inline int __must_check PTR_RET(const void *ptr) +{ + if (IS_ERR(ptr)) + return PTR_ERR(ptr); + else + return 0; +} + #endif #endif /* _LINUX_ERR_H */