mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] device: add dev_WARN_ON and dev_WARN_ONCE
@ 2011-03-16 13:51 Felipe Balbi
  2011-03-16 13:55 ` Felipe Balbi
  0 siblings, 1 reply; 2+ messages in thread
From: Felipe Balbi @ 2011-03-16 13:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Grant Likely, Magnus Damm, Eric W. Biederman, Andi Kleen,
	Linux Kernel Mailing List, Felipe Balbi

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 <balbi@ti.com>
---
 include/linux/device.h |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 1bf5cf0..454d7c1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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))
-- 
1.7.4.rc2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] device: add dev_WARN_ON and dev_WARN_ONCE
  2011-03-16 13:51 [PATCH] device: add dev_WARN_ON and dev_WARN_ONCE Felipe Balbi
@ 2011-03-16 13:55 ` Felipe Balbi
  0 siblings, 0 replies; 2+ messages in thread
From: Felipe Balbi @ 2011-03-16 13:55 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Greg Kroah-Hartman, Grant Likely, Magnus Damm, Eric W. Biederman,
	Andi Kleen, Linux Kernel Mailing List

On Wed, Mar 16, 2011 at 03:51:54PM +0200, Felipe Balbi wrote:
> +#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.

-- 
balbi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-16 13:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-16 13:51 [PATCH] device: add dev_WARN_ON and dev_WARN_ONCE Felipe Balbi
2011-03-16 13:55 ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®