On 1/24/25 11:35, Marek Vasut wrote:
> On 1/24/25 10:10 AM, Jerome Forissier wrote:
>> +#define INITCALL(_call) \
>> +    do { \
>> +        if (_call()) { \
>> +            printf("%s(): initcall %s() failed\n", __func__, \
>> +                   #_call); \
>> +            hang(); \
>> +        } \
>> +    } while (0)
> 
> Can this be turned into some static inline function too , so typechecking 
> would be retained ? Maybe the function can be passed in a function pointer to 
> call ?


Doing the below totally kills the space gain (-160 bytes instead of -2281
on zynqmp_kria_defconfig, with LTO). And it prevents from printing the
function name in case of error, which is nicer than an address
(especially with relocation at play).

============
diff --git a/include/initcall.h b/include/initcall.h
index 220a55ad84d..097c32e141c 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -12,6 +12,14 @@
 
 _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 
bits");
 
+static inline void INITCALL(int (*_call)(void))
+{
+       if (_call()) {
+               printf("initcall %p failed\n", _call);
+               hang();
+       }
+}
+#if 0
 #define INITCALL(_call) \
        do { \
                if (_call()) { \
@@ -20,6 +28,7 @@ _Static_assert(EVT_COUNT < 256, "Can only support 256 event 
types with 8 bits");
                        hang(); \
                } \
        } while (0)
+#endif
 
 #define INITCALL_EVT(_evt) \
        do { \
============

Regards,
-- 
Jerome

Reply via email to