[PATCH 1/2] driver core: Add dev_WARN_ON() helper

From: Geert Uytterhoeven
Date: Wed Nov 20 2019 - 09:36:32 EST


It is quite useful to print the related device in a warning backtrace.
Hence add a "dev_*" variant of WARN_ON() to handle this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
---
include/linux/device.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index f05c5b92e61f535a..05089c329620472a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1902,6 +1902,9 @@ do { \
WARN_ONCE(condition, "%s %s: " format, \
dev_driver_string(dev), dev_name(dev), ## arg)

+#define dev_WARN_ON(dev, condition) \
+ WARN(condition, "%s %s", dev_driver_string(dev), dev_name(dev))
+
/* Create alias, so I can be autoloaded. */
#define MODULE_ALIAS_CHARDEV(major,minor) \
MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
--
2.17.1