1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_ONCE_LITE_H
3 #define _LINUX_ONCE_LITE_H
5 #include <linux/types.h>
7 /* Call a function once. Similar to DO_ONCE(), but does not use jump label
8 * patching via static keys.
10 #define DO_ONCE_LITE(func, ...) \
11 DO_ONCE_LITE_IF(true, func, ##__VA_ARGS__)
12 #define DO_ONCE_LITE_IF(condition, func, ...) \
14 static bool __section(".data.once") __already_done; \
15 bool __ret_do_once = !!(condition); \
17 if (unlikely(__ret_do_once && !__already_done)) { \
18 __already_done = true; \
21 unlikely(__ret_do_once); \
24 #endif /* _LINUX_ONCE_LITE_H */