diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-01-31 08:53:50 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-01-31 10:43:17 +0100 |
commit | cdc0eed74be6ad296727ae564f5b69b703563020 (patch) | |
tree | fdc9923e4b757dd160e36d939a9e9f68b6edb1ae /include | |
parent | 195b362c035a70a72a54978a9b80f4c212f85bdc (diff) | |
download | barebox-cdc0eed74be6ad296727ae564f5b69b703563020.tar.gz barebox-cdc0eed74be6ad296727ae564f5b69b703563020.tar.xz |
include: <asm-generic/bug.h>: implement WARN_ON_ONCE
We have WARN_ON and WARN_ONCE. Add WARN_ON_ONCE as well to accommodate
Linux driver code using it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220131075350.1869535-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index f20e1b4d65..5d0a458eae 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -50,4 +50,16 @@ } \ unlikely(__ret_warn_once); \ }) + +#define WARN_ON_ONCE(condition) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + __warned = 1; \ + __WARN(); \ + } \ + unlikely(__ret_warn_once); \ +}) + #endif |