mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 12/18] Add dev_WARN_ONCE()
Date: Mon, 20 Mar 2023 16:29:35 +0100	[thread overview]
Message-ID: <20230320152941.3155428-13-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

dev_WARN_ONCE() is like WARN_ONCE(), but with a struct device *argument
to print device context.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/linux/printk.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index a9d1b05f6f..42c29e04dd 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -205,4 +205,17 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
 #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)	\
 	print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true)
 
+#define dev_WARN_ONCE(dev, condition, format...) ({      \
+        static int __warned;			\
+        int __ret_warn_once = !!(condition);	\
+						\
+        if (unlikely(__ret_warn_once)) {	\
+                if (!__warned) { 		\
+                        __warned = 1;		\
+                        dev_warn(dev, format);	\
+                }				\
+        }					\
+        unlikely(__ret_warn_once);		\
+})
+
 #endif
-- 
2.30.2




  parent reply	other threads:[~2023-03-20 15:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 15:29 [PATCH 00/18] USB gadget overhaul Sascha Hauer
2023-03-20 15:29 ` [PATCH 01/18] usb: gadget: fastboot: Allocate IN requests when needed Sascha Hauer
2023-03-20 15:29 ` [PATCH 02/18] usb: gadget: drop gadget_chips.h Sascha Hauer
2023-03-20 15:29 ` [PATCH 03/18] usb: gadget: move files to place where Linux has them Sascha Hauer
2023-03-20 15:29 ` [PATCH 04/18] usb: move include " Sascha Hauer
2023-03-20 15:29 ` [PATCH 05/18] usb: ch9: Update from Linux Kernel Sascha Hauer
2023-03-20 15:29 ` [PATCH 06/18] phy: Add mode setting support Sascha Hauer
2023-03-20 15:29 ` [PATCH 07/18] driver: Add unregister_driver() Sascha Hauer
2023-03-20 15:43   ` Ahmad Fatoum
2023-03-21  8:07     ` Sascha Hauer
2023-03-20 15:29 ` [PATCH 08/18] usb: gadget: Update core to Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 09/18] uuid.h: sync with Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 10/18] usb: gadget: Add super-speed-plus descriptors Sascha Hauer
2023-03-20 15:29 ` [PATCH 11/18] usb: gadget: update composite.c from Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` Sascha Hauer [this message]
2023-03-20 15:29 ` [PATCH 13/18] usb: dwc3: sync with Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 14/18] usb: gadget: dfu: Assign super speed descriptors Sascha Hauer
2023-03-20 15:29 ` [PATCH 15/18] usb: gadget: fastboot: Add " Sascha Hauer
2023-03-22  8:28   ` Johannes Zink
2023-03-20 15:29 ` [PATCH 16/18] usb: gadget: mass storage: " Sascha Hauer
2023-03-20 15:29 ` [PATCH 17/18] usb: gadget: u_serial: Put back to list if shutdown Sascha Hauer
2023-03-20 15:29 ` [PATCH 18/18] usb: gadget multi: support USB Super Speed Sascha Hauer

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=20230320152941.3155428-13-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox