[PATCH v2 15/20] include: implement dev_warn_once and friends
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Nov 22 09:29:46 PST 2023
We already have pr_*_once, so duplicate it for dev_warn and friends as
well.
Signed-off-by: Ahmad Fatoum <a.fatoum at 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
More information about the barebox
mailing list