mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-11 15:37:23 +00:00
948f32c856
Add WARN_ONCE definition to allow single time notification of warnings to the user. Taken from Linux kernel (4.17) with slight changes (Removed __section(.data.once)) Signed-off-by: Ramon Fried <ramon.fried@gmail.com> [trini: Drop the musb and dwc3 compat versions] Signed-off-by: Tom Rini <trini@konsulko.com>
52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
#ifndef _LINUX_BUG_H
|
|
#define _LINUX_BUG_H
|
|
|
|
#include <vsprintf.h> /* for panic() */
|
|
#include <linux/build_bug.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/printk.h>
|
|
|
|
#define BUG() do { \
|
|
printk("BUG at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
|
|
panic("BUG!"); \
|
|
} while (0)
|
|
|
|
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
|
|
|
|
#define WARN_ON(condition) ({ \
|
|
int __ret_warn_on = !!(condition); \
|
|
if (unlikely(__ret_warn_on)) \
|
|
printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
|
|
unlikely(__ret_warn_on); \
|
|
})
|
|
|
|
#define WARN(condition, format...) ({ \
|
|
int __ret_warn_on = !!(condition); \
|
|
if (unlikely(__ret_warn_on)) \
|
|
printf(format); \
|
|
unlikely(__ret_warn_on); \
|
|
})
|
|
|
|
#define WARN_ON_ONCE(condition) ({ \
|
|
static bool __warned; \
|
|
int __ret_warn_once = !!(condition); \
|
|
\
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
__warned = true; \
|
|
WARN_ON(1); \
|
|
} \
|
|
unlikely(__ret_warn_once); \
|
|
})
|
|
|
|
#define WARN_ONCE(condition, format...) ({ \
|
|
static bool __warned; \
|
|
int __ret_warn_once = !!(condition); \
|
|
\
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
__warned = true; \
|
|
WARN(1, format); \
|
|
} \
|
|
unlikely(__ret_warn_once); \
|
|
})
|
|
|
|
#endif /* _LINUX_BUG_H */
|