From 0777b000f1118af4abd7adf18bcff358fe8afd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Mon, 20 Feb 2023 21:42:22 +0100 Subject: [PATCH] linuxkpi: Define `dev_WARN()` and `dev_WARN_ONCE()` Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D39049 --- sys/compat/linuxkpi/common/include/linux/device.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index 18f2eef895c..09a61bdd0a6 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -199,6 +199,20 @@ show_class_attr_string(struct class *class, #define dev_printk(lvl, dev, fmt, ...) \ device_printf((dev)->bsddev, fmt, ##__VA_ARGS__) +#define dev_WARN(dev, fmt, ...) \ + device_printf((dev)->bsddev, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__) + +#define dev_WARN_ONCE(dev, condition, fmt, ...) do { \ + static bool __dev_WARN_ONCE; \ + bool __ret_warn_on = (condition); \ + if (unlikely(__ret_warn_on)) { \ + if (!__dev_WARN_ONCE) { \ + __dev_WARN_ONCE = true; \ + device_printf((dev)->bsddev, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__); \ + } \ + } \ +} while (0) + #define dev_info_once(dev, ...) do { \ static bool __dev_info_once; \ if (!__dev_info_once) { \