1, recently in the write I2C under the EEPROM driver, but found that using the I2c_new_probed_device function can not enumerate to the device, so want to debug the function (in driver/i2c/i2c-core.c), see some of the debugging information is as follows:
I2c_new_probed_device (...)
{
...
if (addr_list[i] = = i2c_client_end) {
dev_dbg (&adap->dev, "probing failed, no device found\n");
return NULL;
}
...
}
However, the driver module is loaded and the debugging information is not printed (the debug information is also not found after executing the DMESG command).
2, list the dev_dbg source code realization: (Include/linux/device.h)
#if defined (DEBUG)
#define DEV_DBG (Dev, format, arg ...) \
DEV_PRINTK (kern_debug, Dev, format, # # ARG)
Problem, just define the debug macro before referencing the header file #include/linux/device.h.
Modify the code in Include/linux/i2c.h as follows:
#define DEBUG/* Add for DEBUG EEPROM * *
#include <linux/device.h>/* for struct device * *
#undef Debug/* Add for DEBUG EEPROM * *
After loading the drive module, there is no debug information to print out. The following figure:
But after executing the DMESG command probing failed, no device found has been able to print out the following figure:
That's why
But after this is turned on, it is not smooth output information, because PRINTK has the default level of information.
linux/kernel file
#define KERN_EMERG "<0>"
#define KERN_ALERT "<1>"
#define KERN_CRIT "<2 > "
#define KERN_ERR " <3> " &NBSP;&NBSP;&NBSP;&NBSP
#define KERN_WARNING "<4>" &NBSP;&NBSP;&NBSP;&NBSP
#define KERN_NOTICE "<5>" &NBSP;&NBSP;&NBSP;&NBSP
#define KERN_INFO "<6>" &NBSP;&NBSP;&NBSP
#define KERN_DEBUG "<7>" &NBSP;&NBSP
You can see that Kern_debug is the lowest level.
2. modify file Kernel/printk file
#define DEFAULT_MESSAGE_LOGLEVEL 4
#define MINIMUM_CONSOLE_LOGLEVEL 1
#define Default_console_loglevel 8
Where Default_console_loglevel is the lowest level of terminal CONSOLE output, which is more severe than this. When the value is 7, the debug information cannot be exported, and the modification to 8 has all the output. PS: So you can
echo 8 >/PROC/SYS/KERNEL/PRINTK