Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

err.h: add INIT_ERR_PTR() macro

Add INIT_ERR_PTR() macro to initialize static variables with error
pointers. This might be useful for specific case where there is a static
variable initialized to an error condition and then later set to the
real handle once probe finish/completes.

This is to handle compilation problems like:

error: initializer element is not constant

where ERR_PTR() can't be used.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20251031130835.7953-2-ansuelsmth@gmail.com
[bjorn: Added () suffix on macro references]
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Christian Marangi and committed by
Bjorn Andersson
652a86b2 dc5db350

+8
+8
include/linux/err.h
··· 41 41 return (void *) error; 42 42 } 43 43 44 + /** 45 + * INIT_ERR_PTR - Init a const error pointer. 46 + * @error: A negative error code. 47 + * 48 + * Like ERR_PTR(), but usable to initialize static variables. 49 + */ 50 + #define INIT_ERR_PTR(error) ((void *)(error)) 51 + 44 52 /* Return the pointer in the percpu address space. */ 45 53 #define ERR_PTR_PCPU(error) ((void __percpu *)(unsigned long)ERR_PTR(error)) 46 54