3、注意dev_printk的打印级别:
dev_printk(KERN_DEBUG , dev , format , ## arg)
这里有个KERN_DEBUG的打印级别,其他级别如下(include/linux/kernel.h中):
#define KERN_EMERG "<0>" /* system is unusable */
#define KERN_ALERT "<1>" /* action must be taken immediately */
#define KERN_CRIT "<2>" /* critical conditions */
#define KERN_ERR "<3>" /* error conditions */
#define KERN_WARNING "<4>" /* warning conditions */
#define KERN_NOTICE "<5>" /* normal but significant condition */
#define KERN_INFO "<6>" /* informational */
#define KERN_DEBUG "<7>" /* debug-level messages */
可以看到KERN_DEBUG级别最低为7。
再看/kernel/printk.c下的一个宏:
#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
该行表示只有打印级别高于DEFAULT_CONSOLE_LOGLEVEL(值小于DEFAULT_CONSOLE_LOGLEVEL的值)的打印才会出现在终端上。而 KERN_DEBUG也为7,所以我们的调试不会直接打印出来。
将该行修改为:
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* anything MORE serious than KERN_DEBUG */
来保证KERN_DEBU的值小于DEFAULT_CONSOLE_LOGLEVEL,然后加载eeprom驱动模块后:调试信息能够正确打印出来。