mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-29 13:23:23 +01:00
err.h: use __always_inline on all error pointer helpers
While testing randconfig builds on s390, I came across a link failure with CONFIG_DMA_SHARED_BUFFER disabled: ERROR: modpost: "dma_buf_put" [drivers/iommu/iommufd/iommufd.ko] undefined! The problem here is that IS_ERR() is not inlined and dead code elimination fails as a consequence. The err.h helpers all turn into a trivial assignment of a bit mask and should never result in a function call, so force them to always be inline. This should generally result in better object code aside from avoiding the link failure above. Link: https://lore.kernel.org/[email protected] Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Tested-by: Tamir Duberstein <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Andriy Shevchenko <[email protected]> Cc: Ansuel Smith <[email protected]> Cc: Bjorn Andersson <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
1 parent
9a79524d14
commit
94bfc7f3b0
1 file changed
+6
-6
+6
-6
@@ -36,7 +36,7 @@
|
||||
*
|
||||
* Return: A pointer with @error encoded within its value.
|
||||
*/
|
||||
static inline void * __must_check ERR_PTR(long error)
|
||||
static __always_inline void * __must_check ERR_PTR(long error)
|
||||
{
|
||||
return (void *) error;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ static inline void * __must_check ERR_PTR(long error)
|
||||
* @ptr: An error pointer.
|
||||
* Return: The error code within @ptr.
|
||||
*/
|
||||
static inline long __must_check PTR_ERR(__force const void *ptr)
|
||||
static __always_inline long __must_check PTR_ERR(__force const void *ptr)
|
||||
{
|
||||
return (long) ptr;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ static inline long __must_check PTR_ERR(__force const void *ptr)
|
||||
* @ptr: The pointer to check.
|
||||
* Return: true if @ptr is an error pointer, false otherwise.
|
||||
*/
|
||||
static inline bool __must_check IS_ERR(__force const void *ptr)
|
||||
static __always_inline bool __must_check IS_ERR(__force const void *ptr)
|
||||
{
|
||||
return IS_ERR_VALUE((unsigned long)ptr);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ static inline bool __must_check IS_ERR(__force const void *ptr)
|
||||
*
|
||||
* Like IS_ERR(), but also returns true for a null pointer.
|
||||
*/
|
||||
static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
|
||||
static __always_inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
|
||||
{
|
||||
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
|
||||
* Explicitly cast an error-valued pointer to another pointer type in such a
|
||||
* way as to make it clear that's what's going on.
|
||||
*/
|
||||
static inline void * __must_check ERR_CAST(__force const void *ptr)
|
||||
static __always_inline void * __must_check ERR_CAST(__force const void *ptr)
|
||||
{
|
||||
/* cast away the const */
|
||||
return (void *) ptr;
|
||||
@@ -122,7 +122,7 @@ static inline void * __must_check ERR_CAST(__force const void *ptr)
|
||||
*
|
||||
* Return: The error code within @ptr if it is an error pointer; 0 otherwise.
|
||||
*/
|
||||
static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
|
||||
static __always_inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
|
||||
{
|
||||
if (IS_ERR(ptr))
|
||||
return PTR_ERR(ptr);
|
||||
|
||||
Reference in new issue
Block a user