Skip to content

Commit c1df5e0

Browse files
nivedita76ardbiesheuvel
authored andcommitted
efi/libstub: Add efi_warn and *_once logging helpers
Add an efi_warn logging helper for warnings, and implement an analog of printk_once for once-only logging. Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> Link: https://lore.kernel.org/r/20200914213535.933454-1-nivedita@alum.mit.edu Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 726bd89 commit c1df5e0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

drivers/firmware/efi/libstub/efistub.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,34 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
5252

5353
#define efi_info(fmt, ...) \
5454
efi_printk(KERN_INFO fmt, ##__VA_ARGS__)
55+
#define efi_warn(fmt, ...) \
56+
efi_printk(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
5557
#define efi_err(fmt, ...) \
5658
efi_printk(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__)
5759
#define efi_debug(fmt, ...) \
5860
efi_printk(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__)
5961

62+
#define efi_printk_once(fmt, ...) \
63+
({ \
64+
static bool __print_once; \
65+
bool __ret_print_once = !__print_once; \
66+
\
67+
if (!__print_once) { \
68+
__print_once = true; \
69+
efi_printk(fmt, ##__VA_ARGS__); \
70+
} \
71+
__ret_print_once; \
72+
})
73+
74+
#define efi_info_once(fmt, ...) \
75+
efi_printk_once(KERN_INFO fmt, ##__VA_ARGS__)
76+
#define efi_warn_once(fmt, ...) \
77+
efi_printk_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
78+
#define efi_err_once(fmt, ...) \
79+
efi_printk_once(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__)
80+
#define efi_debug_once(fmt, ...) \
81+
efi_printk_once(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__)
82+
6083
/* Helper macros for the usual case of using simple C variables: */
6184
#ifndef fdt_setprop_inplace_var
6285
#define fdt_setprop_inplace_var(fdt, node_offset, name, var) \

0 commit comments

Comments
 (0)