There's more...

Linux drivers do not use the printk function directly. They use, in order of preference, subsystem-specific messages (such as netdev or v4l) or the dev_* and pr_* family of functions. The latter are described in the following table:

Device message

Generic message

Printk symbol

dev_emerg

pr_emerg

KERN_EMERG

dev_alert

pr_alert

KERN_ALERT

dev_crit

pr_crit

KERN_CRIT

dev_err

pr_err

KERN_ERR

dev_warn

pr_warn

KERN_WARNING

dev_notice

pr_notice

KERN_NOTICE

dev_info

pr_info

KERN_INFO

dev_dbg

pr_debug

KERN_DEBUG

 

To enable the debug messages within a driver, you may do either of the following:

  • Define DEBUG in a macro before any other header file in your driver source, as follows:
#define DEBUG 

Of course, the kernel needs to be recompiled and reprogrammed for the define above to take effect.

  • Use the dynamic debug kernel feature, which allows to control debug statements at runtime. You can then enable/disable all dev_dbg and pr_debug debug messages with granularity through debugfs.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset