How are dev_*() family functions useful while debugging the Linux kernel?
The pr_*()
functions are the same as plain printk()
, but with the KERN_xxx
log level already included.
The dev_*()
functions are the same as the corresponding pr_*()
functions, but also print identifying information about the struct device
.
If your message is related to some device (which is normally the case in drivers), you should use dev_*()
.
For example, in a USB driver:
struct usb_device *usb_dev;
dev_info(&usb_dev->dev, "hello\n");
struct usb_interface *usb_intf;
dev_info(&usb_intf->dev, "hello\n");
or in a PCI driver:
struct pci_dev *pci;
dev_info(&pci->dev, "hello\n");
dev_*
functions are similar to pr_*
, but also print some information about device(struct device
), passed to them as the first argument. This information may help to filter system log for messages, belonging to concrete device.
So, you can use dev_*
function instead of pr_*
whenever message is applicable to concrete device(and you have destriptor of it).