Order of preference - printk() vs dev_dbg() vs netdev_dbg() Order of preference - printk() vs dev_dbg() vs netdev_dbg() linux linux

Order of preference - printk() vs dev_dbg() vs netdev_dbg()


Each kernel subsystem usually has its own printk format. So when you are using network subsystem, you have to use netdev_dbg; when you are using V4L you have to use v4l_dbg. It standardizes the output format within the subsystem.

netdev_dbg it is not the absolutly prefered print style. It is prefered if you are working with a netdevice. If you take a look at the source code here you will see that it is required a struct netdevice object, and you have this kind of object only if you are working in the network subsystem

Probably the message is confuse because it should suggest you to use the printing method of the subsystem where you are working on. You have got the warning because you are using prink() which is the raw way to print something.

Depending on what you are coding you should use a different print style:

printk(): never

pr_debug(): always good

dev_dbg(): prefered when you have a struct device object

netdev_dbg(): prefered when you have a struct netdevice object

[something]_dbg(): prefered when you have a that something object