diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-06-15 09:28:13 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-08-19 07:36:15 +0200 |
commit | 0dc2fbcea236a1d610f28f7fb17cd6aee49885f7 (patch) | |
tree | ac40b06df7061d264e08e3da65a59fe412f19c04 /include/asm-generic | |
parent | 6ce3d1cfff65071d51973a8008c92be5005f5d0a (diff) | |
download | barebox-0dc2fbcea236a1d610f28f7fb17cd6aee49885f7.tar.gz barebox-0dc2fbcea236a1d610f28f7fb17cd6aee49885f7.tar.xz |
Add WARN_ONCE() macro
This adds WARN_ONCE from the Linux Kernel. It is useful to warn only
once when we would otherwise spam the log.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/bug.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 8583d2425f..82b78261fc 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -34,4 +34,17 @@ unlikely(__ret_warn_on); \ }) #endif + +#define WARN_ONCE(condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) { \ + if (WARN(!__warned, format)) { \ + __warned = 1; \ + dump_stack(); \ + } \ + } \ + unlikely(__ret_warn_once); \ +}) #endif |