diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-03-17 12:33:22 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-03-24 09:34:25 +0100 |
commit | 068ba9026772423c955d568078489cd76bc231a8 (patch) | |
tree | f776f7d7eb5771ce07212a0a1e71ead5869cb188 | |
parent | 4667c43c08650029558bf1998989ef7d7d96ebe2 (diff) | |
download | barebox-068ba9026772423c955d568078489cd76bc231a8.tar.gz |
Add dev_WARN_ONCE()
dev_WARN_ONCE() is like WARN_ONCE(), but with a struct device *argument
to print device context.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | include/linux/printk.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h index a9d1b05f6f..42c29e04dd 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -205,4 +205,17 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type, #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true) +#define dev_WARN_ONCE(dev, condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) { \ + if (!__warned) { \ + __warned = 1; \ + dev_warn(dev, format); \ + } \ + } \ + unlikely(__ret_warn_once); \ +}) + #endif |