Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa9ee9c4 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Linus Torvalds
Browse files

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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d404ab0a
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -52,6 +52,14 @@ static inline void * __must_check ERR_CAST(const void *ptr)
	return (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


#endif /* _LINUX_ERR_H */
#endif /* _LINUX_ERR_H */