fix dev_printk to work even in the absence of am attached driver
PATCH 1/1 fix dev_printk to work even in the absence of am attached driver
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
include/linux/device.h +1 -1
@@ -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...) \
include/linux/device.h line 403
Quoted 4 lines · James Bottomley
/* debugging and troubleshooting/diagnostic helpers. */
#definedev_printk(level, dev, format, arg...)\include/linux/device.h +1
-1- 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
Quoted 4 lines · Greg KH
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 =====
include/linux/device.h +1 -1
@@ -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...) \
Quoted 9 lines · James Bottomley
Quoted 4 lines · Greg KH
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