device: add dev_WARN_ON and dev_WARN_ONCE
PATCH 1/1 device: add dev_WARN_ON and dev_WARN_ONCE
it's quite useful to print the device name on the stack dump caused by WARN(), but there are other cases where we might want to use WARN_ON() or WARN_ONCE, introduce helpers similar to dev_WARN() for those cases too.
Signed-off-by Felipe Balbi <[email protected]>
--- include/linux/device.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
include/linux/device.h +9 -1
@@ -739,13 +739,21 @@ do { \#endif /* -* dev_WARN() acts like dev_printk(), but with the key difference +* dev_WARN*() acts like dev_printk(), but with the key difference * of using a WARN/WARN_ON to get the message out, including the * file/line information and a backtrace. */ #define dev_WARN(dev, format, arg...) \ WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); +#define dev_WARN_ON(dev, condition, format, arg...) \ + WARN_ON(condition, "Device: %s\n" format, \ + dev_driver_string(dev), ## arg) + +#define dev_WARN_ONCE(dev, condition, format, arg...) \ + WARN_ONCE(condition, "Device %s\n" format, \ + dev_driver_string(dev), ## arg) +/* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV (major,minor) \ MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
Signature · 1 line
1.7.4.rc2
include/linux/device.h do { \ · line 751
Quoted 3 lines · Felipe Balbi
include/linux/device.h +3
-0+#define dev_WARN_ON(dev, condition, format, arg...) \ + WARN_ON(condition, "Device: %s\n" format, \ + dev_driver_string(dev), ## arg)
oops, I mis-used WARN_ON. Will fix and resend... just a sec.
Signature · 1 line
balbi