Skip to contentSkip to conversation

dev_printk and new-style class devices

PATCH Jean Delvare 1 participant 1 message Mar 9, 2007 Driver core

lore
Share & tools
lore
#0 lore raw

Hi Greg, all,

As the new-style class devices (as opposed to old-style struct class_device) are becoming more widely used, I noticed that the dev_printk-based functions are not working properly with these. New-style class devices have no driver nor bus, almost by definition, and as a result dev_driver_string(), which is used as the first parameter of dev_printk, resolves to an empty string. This causes entries like the following to show in my logs:

i2c-2: adapter [SMBus stub driver] registered

Notice the unaesthetical leading whitespace. In order to fix this problem, I suggest that we extend dev_driver_string to deal with new-style class devices:

---
 drivers/base/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/core.c +2 -1
@@ -57,7 +57,8 @@ bool is_lanana_major(unsigned int major)
 const char *dev_driver_string(struct device *dev)
 {
 	return dev->driver ? dev->driver->name :
-			(dev->bus ? dev->bus->name : "");
+			(dev->bus ? dev->bus->name :
+			(dev->class ? dev->class->name : ""));
 }
 EXPORT_SYMBOL(dev_driver_string);
 

In the case above, the message in the logs now looks like:

i2c-adapter i2c-2: adapter [SMBus stub driver] registered

Which is much better IMHO. Greg, what do you think?

Thanks,

Signature · 1 line
Jean Delvare