[PATCH 2.6] Fix dev_printk to work with unclaimed devices

From: Deepak Saxena
Date: Thu Feb 26 2004 - 13:37:12 EST



I need to do some fixup in platform_notify() and when trying to
use the dev_* print functions for informational messages, they OOPs
b/c the current code assumes that dev->driver exists. This is not the
case since platform_notify() is called before a device has been attached
to any driver.

--- linux-2.5-bk/include/linux/device.h 2004-02-10 14:51:49.000000000 -0700
+++ linux-2.6-ds/include/linux/device.h 2004-02-26 11:10:38.000000000 -0700
@@ -395,7 +395,13 @@

/* debugging and troubleshooting/diagnostic helpers. */
#define dev_printk(level, dev, format, arg...) \
- printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg)
+ do { \
+ if ((dev)->driver) { \
+ printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg); \
+ } else { \
+ printk(level "%s (Unclaimed %s bus device): " format , (dev)->bus_id, (dev)->bus->name , ## arg); \
+ } \
+ } while (0)

#ifdef DEBUG
#define dev_dbg(dev, format, arg...) \

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/