Skip to content

Commit bcdd323

Browse files
Felipe Balbigregkh
authored andcommitted
device: add 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_ONCE. Introduce a helper similar to dev_WARN() for that case too. Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f0e615c commit bcdd323

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/linux/device.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,17 @@ do { \
742742
#endif
743743

744744
/*
745-
* dev_WARN() acts like dev_printk(), but with the key difference
745+
* dev_WARN*() acts like dev_printk(), but with the key difference
746746
* of using a WARN/WARN_ON to get the message out, including the
747747
* file/line information and a backtrace.
748748
*/
749749
#define dev_WARN(dev, format, arg...) \
750750
WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
751751

752+
#define dev_WARN_ONCE(dev, condition, format, arg...) \
753+
WARN_ONCE(condition, "Device %s\n" format, \
754+
dev_driver_string(dev), ## arg)
755+
752756
/* Create alias, so I can be autoloaded. */
753757
#define MODULE_ALIAS_CHARDEV(major,minor) \
754758
MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))

0 commit comments

Comments
 (0)