mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] include: <asm-generic/bug.h>: implement WARN_ON_ONCE
@ 2022-01-31  7:53 Ahmad Fatoum
  2022-01-31  9:43 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-01-31  7:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We have WARN_ON and WARN_ONCE. Add WARN_ON_ONCE as well to accommodate
Linux driver code using it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/asm-generic/bug.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index f20e1b4d65ac..5d0a458eae74 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -50,4 +50,16 @@
 	}					\
 	unlikely(__ret_warn_once);		\
 })
+
+#define WARN_ON_ONCE(condition) ({			\
+	static int __warned;				\
+	int __ret_warn_once = !!(condition);		\
+							\
+	if (unlikely(__ret_warn_once && !__warned)) {	\
+		__warned = 1;				\
+		__WARN();				\
+	}						\
+	unlikely(__ret_warn_once);			\
+})
+
 #endif
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] include: <asm-generic/bug.h>: implement WARN_ON_ONCE
  2022-01-31  7:53 [PATCH] include: <asm-generic/bug.h>: implement WARN_ON_ONCE Ahmad Fatoum
@ 2022-01-31  9:43 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-01-31  9:43 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jan 31, 2022 at 08:53:50AM +0100, Ahmad Fatoum wrote:
> We have WARN_ON and WARN_ONCE. Add WARN_ON_ONCE as well to accommodate
> Linux driver code using it.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  include/asm-generic/bug.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-31  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31  7:53 [PATCH] include: <asm-generic/bug.h>: implement WARN_ON_ONCE Ahmad Fatoum
2022-01-31  9:43 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox