mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 15/20] include: implement dev_warn_once and friends
Date: Wed, 22 Nov 2023 18:29:46 +0100	[thread overview]
Message-ID: <20231122172951.376531-16-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20231122172951.376531-1-a.fatoum@pengutronix.de>

We already have pr_*_once, so duplicate it for dev_warn and friends as
well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - squash IDR hunk into previous commit (Sascha)
---
 include/linux/printk.h | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index cd4c3cb68edb..0e9604bbe967 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -57,7 +57,15 @@ static inline int pr_print(int level, const char *format, ...)
 		(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
 	 })
 
-
+#define __dev_printf_once(level, dev, format, args...) do {	\
+	static bool __print_once;				\
+								\
+	if (!__print_once && (level) <= LOGLEVEL) {		\
+		__print_once = true;				\
+		dev_printf((level), (dev), (format), ##args);	\
+	}							\
+} while (0)
+ 
 #define dev_emerg(dev, format, arg...)		\
 	__dev_printf(0, (dev) , format , ## arg)
 #define dev_alert(dev, format, arg...)		\
@@ -77,6 +85,25 @@ static inline int pr_print(int level, const char *format, ...)
 #define dev_vdbg(dev, format, arg...)		\
 	__dev_printf(8, (dev) , format , ## arg)
 
+#define dev_emerg_once(dev, format, arg...)		\
+	__dev_printf_once(0, (dev) , format , ## arg)
+#define dev_alert_once(dev, format, arg...)		\
+	__dev_printf_once(1, (dev) , format , ## arg)
+#define dev_crit_once(dev, format, arg...)		\
+	__dev_printf_once(2, (dev) , format , ## arg)
+#define dev_err_once(dev, format, arg...)		\
+	__dev_prin_oncetf(3, (dev) , format , ## arg)
+#define dev_warn_once(dev, format, arg...)		\
+	__dev_printf_once(4, (dev) , format , ## arg)
+#define dev_notice_once(dev, format, arg...)		\
+	__dev_printf(_once5, (dev) , format , ## arg)
+#define dev_info_once(dev, format, arg...)		\
+	__dev_printf_once(6, (dev) , format , ## arg)
+#define dev_dbg_once(dev, format, arg...)		\
+	__dev_prin_oncetf(7, (dev) , format , ## arg)
+#define dev_vdbg_once(dev, format, arg...)		\
+	__dev_printf_once(8, (dev) , format , ## arg)
+
 #if LOGLEVEL >= MSG_ERR
 int dev_err_probe(struct device *dev, int err, const char *fmt, ...)
 	__attribute__ ((format(__printf__, 3, 4)));
-- 
2.39.2




  parent reply	other threads:[~2023-11-22 17:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 17:29 [PATCH v2 00/20] prepare for porting OP-TEE communication support Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 01/20] include: provide linux/errno.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 02/20] include: add linux/refcount.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 03/20] bitops: split off linux/bits.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 04/20] include: import <linux/instruction_pointer.h> Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 05/20] asm-generic: split off typeconfused readl and friends Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 06/20] asm-generic: migrate relaxed helpers into asm-generic/io.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 07/20] include: add linux/io.h with strict prototypes Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 08/20] include: import Linux word-at-a-time.h Ahmad Fatoum
2023-11-23  8:16   ` [PATCH] fixup! " Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 09/20] string: implement strscpy Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 10/20] of: add CONFIG_OF for Linux compatibility Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 11/20] include: asm-generic/atomic.h: define atomic_cmpxchg Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 12/20] kbuild: build barebox for -std=gnu11 Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 13/20] include: linux/idr.h: implement more Linux API Ahmad Fatoum
2023-11-30 20:37   ` Sascha Hauer
2023-11-22 17:29 ` [PATCH v2 14/20] test: self: add simple IDR test Ahmad Fatoum
2023-11-22 17:29 ` Ahmad Fatoum [this message]
2023-11-22 17:29 ` [PATCH v2 16/20] include: add blocking notifier aliases Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 17/20] include: add Linux ktime API Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 18/20] of: constify string pointed to by struct of_device_id::compatible Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 19/20] of: define of_devices_ensure_probed_by_compatible Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 20/20] include: add linux/device.h wrapper around driver.h Ahmad Fatoum
2023-11-23 14:50 ` [PATCH v2 00/20] prepare for porting OP-TEE communication support 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=20231122172951.376531-16-a.fatoum@pengutronix.de \
    --to=a.fatoum@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