public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix dev_printk to work even in the absence of am attached driver
@ 2004-04-19 20:39 James Bottomley
  2004-04-22 22:07 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2004-04-19 20:39 UTC (permalink / raw)
  To: greg; +Cc: Linux Kernel

dev_printk makes an incredibly convenient hook to hang a logging
infrastructure.  For that reason, it would be very useful to make all
device driver logging go through it.

Unfortunately in SCSI we can't do this yet because we need to log
messages even when the device doesn't have a bound driver (either
because the user has chosen not to load it or because we're starting up
or shutting down).

The attached makes dev_printk work even in the absence of a bound driver
so we should now be able to use it at all points in the lifecycle of a
SCSI device.

James
Index: include/linux/device.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/linux/device.h,v
retrieving revision 1.9
diff -u -r1.9 device.h
--- a/include/linux/device.h	15 Apr 2004 18:05:25 -0000	1.9
+++ b/include/linux/device.h	19 Apr 2004 20:36:57 -0000
@@ -400,7 +400,7 @@
 
 /* debugging and troubleshooting/diagnostic helpers. */
 #define dev_printk(level, dev, format, arg...)	\
-	printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg)
+	printk(level "%s %s: " format , (dev)->driver ? (dev)->driver->name : "(unbound)", (dev)->bus_id , ## arg)
 
 #ifdef DEBUG
 #define dev_dbg(dev, format, arg...)		\




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

* Re: [PATCH] fix dev_printk to work even in the absence of am attached driver
  2004-04-19 20:39 [PATCH] fix dev_printk to work even in the absence of am attached driver James Bottomley
@ 2004-04-22 22:07 ` Greg KH
  2004-05-11 14:00   ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2004-04-22 22:07 UTC (permalink / raw)
  To: James Bottomley; +Cc: Linux Kernel

On Mon, Apr 19, 2004 at 03:39:57PM -0500, James Bottomley wrote:
>  /* debugging and troubleshooting/diagnostic helpers. */
>  #define dev_printk(level, dev, format, arg...)	\
> -	printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg)
> +	printk(level "%s %s: " format , (dev)->driver ? (dev)->driver->name : "(unbound)", (dev)->bus_id , ## arg)

But doesn't this cause the string "(unbound)" to be created for every
dev_printk() call in the code?  I don't think gcc can optimize that very
well.  How about making a global string just for that, otherwise the
size police will come after me for adding such a patch :)

thanks,

greg k-h

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

* Re: [PATCH] fix dev_printk to work even in the absence of am attached driver
  2004-04-22 22:07 ` Greg KH
@ 2004-05-11 14:00   ` James Bottomley
  2004-05-11 23:39     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2004-05-11 14:00 UTC (permalink / raw)
  To: Greg KH; +Cc: Linux Kernel

On Thu, 2004-04-22 at 17:07, Greg KH wrote: 
> But doesn't this cause the string "(unbound)" to be created for every
> dev_printk() call in the code?  I don't think gcc can optimize that very
> well.  How about making a global string just for that, otherwise the
> size police will come after me for adding such a patch :)

OK, I can't find an elegant way of making it global, so I think the best
thing to do is just leave it blank for no driver (gcc can optimise that
case). 

James 

===== include/linux/device.h 1.117 vs edited =====
--- 1.117/include/linux/device.h	Mon Apr 12 12:54:25 2004
+++ edited/include/linux/device.h	Tue May 11 08:58:44 2004
@@ -400,7 +400,7 @@
 
 /* debugging and troubleshooting/diagnostic helpers. */
 #define dev_printk(level, dev, format, arg...)	\
-	printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg)
+	printk(level "%s %s: " format , (dev)->driver ? (dev)->driver->name : "" , (dev)->bus_id , ## arg)
 
 #ifdef DEBUG
 #define dev_dbg(dev, format, arg...)		\


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

* Re: [PATCH] fix dev_printk to work even in the absence of am attached driver
  2004-05-11 14:00   ` James Bottomley
@ 2004-05-11 23:39     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-05-11 23:39 UTC (permalink / raw)
  To: James Bottomley; +Cc: Linux Kernel

On Tue, May 11, 2004 at 09:00:47AM -0500, James Bottomley wrote:
> On Thu, 2004-04-22 at 17:07, Greg KH wrote: 
> > But doesn't this cause the string "(unbound)" to be created for every
> > dev_printk() call in the code?  I don't think gcc can optimize that very
> > well.  How about making a global string just for that, otherwise the
> > size police will come after me for adding such a patch :)
> 
> OK, I can't find an elegant way of making it global, so I think the best
> thing to do is just leave it blank for no driver (gcc can optimise that
> case). 

Ok, I can live with this, thanks.  Applied.

greg k-h

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

end of thread, other threads:[~2004-05-11 23:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-19 20:39 [PATCH] fix dev_printk to work even in the absence of am attached driver James Bottomley
2004-04-22 22:07 ` Greg KH
2004-05-11 14:00   ` James Bottomley
2004-05-11 23:39     ` Greg KH

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