* [PATCH 2.6] Fix dev_printk to work with unclaimed devices
@ 2004-02-26 18:34 Deepak Saxena
2004-02-26 18:45 ` Linus Torvalds
2004-02-26 18:53 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Deepak Saxena @ 2004-02-26 18:34 UTC (permalink / raw)
To: greg; +Cc: akpm, torvalds, linux-kernel
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...) \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6] Fix dev_printk to work with unclaimed devices
2004-02-26 18:34 [PATCH 2.6] Fix dev_printk to work with unclaimed devices Deepak Saxena
@ 2004-02-26 18:45 ` Linus Torvalds
2004-02-26 18:53 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2004-02-26 18:45 UTC (permalink / raw)
To: Deepak Saxena; +Cc: greg, akpm, linux-kernel
On Thu, 26 Feb 2004, Deepak Saxena wrote:
>
> 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.
Make it a real function with varags, please.
On the other hand, it also is probably just _wrong_ to use "dev_printk()"
if you aren't the driver for the device.
Linus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6] Fix dev_printk to work with unclaimed devices
2004-02-26 18:34 [PATCH 2.6] Fix dev_printk to work with unclaimed devices Deepak Saxena
2004-02-26 18:45 ` Linus Torvalds
@ 2004-02-26 18:53 ` Greg KH
2004-02-26 20:47 ` Deepak Saxena
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2004-02-26 18:53 UTC (permalink / raw)
To: Deepak Saxena; +Cc: akpm, torvalds, linux-kernel
On Thu, Feb 26, 2004 at 11:34:39AM -0700, Deepak Saxena wrote:
>
> 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.
Yeah, this "limitation" of the dev_* printks have been known for a
while, and it was determined that for situations like this, it's not
worth using those calls.
I have a patch somewhere in my tree that will give you a nice WARN()
output if this ever happens, so as to help when trying to port a new bus
to the driver model, but it's too ugly for mainline. Ah, found it, it's
below...
thanks,
greg k-h
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Thu Feb 26 10:48:37 2004
+++ b/include/linux/device.h Thu Feb 26 10:48:37 2004
@@ -394,8 +394,20 @@
extern void firmware_unregister(struct subsystem *);
/* debugging and troubleshooting/diagnostic helpers. */
+#ifdef CONFIG_DEBUG_DEV_PRINTK
+#define dev_printk(level, dev, format, arg...) \
+ do { \
+ if (!(dev) || !(dev)->driver) \
+ WARN_ON(1); \
+ else \
+ printk(level "%s %s: " format , \
+ (dev)->driver->name , \
+ (dev)->bus_id , ## arg); \
+ } while (0)
+#else
#define dev_printk(level, dev, format, arg...) \
printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg)
+#endif
#ifdef DEBUG
#define dev_dbg(dev, format, arg...) \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6] Fix dev_printk to work with unclaimed devices
2004-02-26 18:53 ` Greg KH
@ 2004-02-26 20:47 ` Deepak Saxena
0 siblings, 0 replies; 4+ messages in thread
From: Deepak Saxena @ 2004-02-26 20:47 UTC (permalink / raw)
To: Greg KH; +Cc: akpm, torvalds, linux-kernel
On Feb 26 2004, at 10:53, Greg KH was caught saying:
> On Thu, Feb 26, 2004 at 11:34:39AM -0700, Deepak Saxena wrote:
> >
> > 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.
>
> Yeah, this "limitation" of the dev_* printks have been known for a
> while, and it was determined that for situations like this, it's not
> worth using those calls.
I can just use printks as it is only two quick log messages at
init time.
Tnx,
~Deepak
--
Deepak Saxena - dsaxena at plexity dot net - http://www.plexity.net/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-26 20:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-26 18:34 [PATCH 2.6] Fix dev_printk to work with unclaimed devices Deepak Saxena
2004-02-26 18:45 ` Linus Torvalds
2004-02-26 18:53 ` Greg KH
2004-02-26 20:47 ` Deepak Saxena
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox