bug.h: introduce WARN_ONCE
PATCH v2 1/1 bug.h: introduce WARN_ONCE
From: Ramon Fried <[email protected]>
Add WARN_ONCE definition to allow single time notification of warnings to the user.
Change-Id: If14d878dba04f3c976c0c2ae079a0f7642047006
---
v2: accidently commited the wrong file. noticed by Masahiro Yamada
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 · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/1 bug.h: introduce WARN_ONCE
Quoted 6 lines · Ramon Fried
From: Ramon Fried <[email protected]>
Add
WARN_ONCEdefinition to allow single time notification of warnings to the user.Change-Id: If14d878dba04f3c976c0c2ae079a0f7642047006
You forgot the Signed-off-by line (which I can't fix, sorry) and while at it need to mention the version of the kernel this comes from, and no Change-Id lines please, 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/20180605/7f071bcc/attachment.sig>
PATCH v2 1/1 bug.h: introduce WARN_ONCE
Quoted 11 lines · Tom Rini
Quoted 6 lines · Ramon Fried
From: Ramon Fried <[email protected]>
Add
WARN_ONCEdefinition to allow single time notification of warnings to the user.Change-Id: If14d878dba04f3c976c0c2ae079a0f7642047006
You forgot the Signed-off-by line (which I can't fix, sorry) and while at it need to mention the version of the kernel this comes from, and no
Hi Tom.
Terribly sorry for the bad patch. I will resend shorty.
Regarding the Linux kernel version it came from, this is not just a copy paste, I had to change it a bit (removed the __section(.data.once).
I will add to the commit message the version I referenced it from though.
Quoted 1 line
Change-Id lines please, thanks!
Sure, I don't even know how it slipped in, probably a system wide configuration...
Thanks,
Ramon.
Quoted 3 lines
--
Tom