diff options
| author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2011-03-22 19:34:05 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:11 -0400 |
| commit | fa9ee9c4b9885dfdf8eccac19b8b4fc8a7c53288 (patch) | |
| tree | 7fa3808a38b2d8f161d750156804e643288e4304 /include/linux | |
| parent | d404ab0a1133e95557bb7deab2a49b348dfeba85 (diff) | |
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 <u.kleine-koenig@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/err.h | 8 |
1 files changed, 8 insertions, 0 deletions
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) | |||
| 52 | return (void *) ptr; | 52 | return (void *) ptr; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | static inline int __must_check PTR_RET(const void *ptr) | ||
| 56 | { | ||
| 57 | if (IS_ERR(ptr)) | ||
| 58 | return PTR_ERR(ptr); | ||
| 59 | else | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 55 | #endif | 63 | #endif |
| 56 | 64 | ||
| 57 | #endif /* _LINUX_ERR_H */ | 65 | #endif /* _LINUX_ERR_H */ |
