]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bug.h: introduce WARN_ONCE
authorRamon Fried <ramon.fried@gmail.com>
Tue, 5 Jun 2018 21:38:59 +0000 (00:38 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 7 Jun 2018 21:08:06 +0000 (17:08 -0400)
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>
drivers/usb/dwc3/linux-compat.h
drivers/usb/musb-new/linux-compat.h
include/linux/bug.h

index 35850f91a36dd47159c7f4b399cf9725a7c90103..82793765bea24d05937de623b789999244e11127 100644 (file)
@@ -11,7 +11,6 @@
 #ifndef __DWC3_LINUX_COMPAT__
 #define __DWC3_LINUX_COMPAT__
 
-#define WARN(val, format, arg...)      debug(format, ##arg)
 #define dev_WARN(dev, format, arg...)  debug(format, ##arg)
 
 static inline size_t strlcat(char *dest, const char *src, size_t n)
index 7bb53d2b198ed4269abdc6168a205774b1d281be..f366ae58e877e6c5e80e803f7bd91e5d88d141c2 100644 (file)
@@ -5,12 +5,6 @@
 #include <linux/list.h>
 #include <linux/compat.h>
 
-#define WARN(condition, fmt, args...) ({       \
-       int ret_warn = !!condition;             \
-       if (ret_warn)                           \
-               printf(fmt, ##args);            \
-       ret_warn; })
-
 #define device_init_wakeup(dev, a) do {} while (0)
 
 #define platform_data device_data
index f07bb716fc044bf7b68700b2fc1f481f25efe5d3..29f84168a38d597534793d7651b677c32f4461c1 100644 (file)
        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);                    \
        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 */