这个宏定义为:#define dev_printk(level, dev, format, arg...)/printk(level "%s %s: " format , dev_driver_string(dev) , (dev)->bus_id , ## arg)#ifdef DEBUG#define dev_dbg(dev, format, arg...)/dev_printk(KERN_DEBUG , dev , format , ## arg)#elsestatic/*inline*/int __attribute__ ((format (printf, 2, 3)))dev_dbg(struct device * dev, constchar * fmt, ...){return 0;}#endif同样,要想输出dev_dbg中的信息,首先要求定义DEBUG宏。此外由于它使用了KERN_DEBUG这一输出级别,还必须在内核参数中使用ignore_loglevel。再不然就直接修改它的定义!使用这个宏的好处在于它可以输出驱动或者相关信息的名称:/*** dev_driver_string - Return a device's driver name, if at all possible* @dev: struct device to get the name of** Will return the device's driver's name if it is bound to a device.If* the device is not bound to a device, it will return the name of the bus* it is attached to.If it is not attached to a bus either, an empty* string will be returned.*/constchar *dev_driver_string(struct device *dev){return dev->driver ? dev->driver->name :(dev->bus ? dev->bus->name :(dev->class ? dev->class->name : ""));}其实意义不是很大。还有几个相似的宏:#define dev_err(dev, format, arg...)/dev_printk(KERN_ERR , dev , format , ## arg)#define dev_info(dev, format, arg...)/dev_printk(KERN_INFO , dev , format , ## arg)#define dev_warn(dev, format, arg...)/dev_printk(KERN_WARNING , dev , format , ## arg)#define dev_notice(dev, format, arg...)/dev_printk(KERN_NOTICE , dev , format , ## arg)只是其输出级别不一样而已。