From: Ramon Fried <ramon.fried@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] bug.h: introduce WARN_ONCE
Date: Tue, 29 May 2018 15:46:39 +0300 [thread overview]
Message-ID: <20180529124639.13172-1-ramon.fried@gmail.com> (raw)
From: Ramon Fried <ramon.fried@linaro.org>
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(+)
diff --git a/include/linux/bug.h b/include/linux/bug.h
index f07bb716fc0..e43871dee44 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -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 */
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next reply other threads:[~2018-05-29 12:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 12:46 Ramon Fried [this message]
2018-06-05 14:45 ` [U-Boot] [U-Boot,v2] bug.h: introduce WARN_ONCE Tom Rini
2018-06-05 18:27 ` Ramon Fried
2018-06-05 21:32 [U-Boot] [PATCH v2] " Ramon Fried
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180529124639.13172-1-ramon.fried@gmail.com \
--to=ramon.fried@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.