]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
include/linux/err.h: add a function to cast error-pointers to a return value
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 22 Mar 2011 23:34:05 +0000 (16:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Mar 2011 00:44:11 +0000 (17:44 -0700)
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 <u.kleine-koenig@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/err.h

index 448afc12c78afe6157929010a7fba01a6d63ba8e..f2edce25a76b64f91701cdbd2c680dce19b90706 100644 (file)
@@ -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 */