bug.h: introduce WARN_ONCE
PATCH v3 1/1 bug.h: introduce WARN_ONCE
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 <[email protected]>
---
Facepalm, missed that it was actually a v3 and not a v2.
v2: accidently commited the wrong file. noticed by Masahiro Yamada
v3: removed change-id, added taken from description to commit message.
include/linux/bug.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/linux/bug.h +18 -0
@@ -20,6 +20,13 @@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); \
@@ -31,4 +38,15 @@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 */
Signature · 1 line
2.17.1
PATCH v3 1/1 bug.h: introduce WARN_ONCE
Quoted 6 lines · Ramon Fried
Add
WARN_ONCEdefinition 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 <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180608/838c3047/attachment.sig>