Introduction and methods of linux and android debugging tools
1. device_create_file () Create an attribute file under/sys/class/to complete data operations by reading and writing this attribute file.
For example, the following section describes how to call the probe function driven by the keyboard.
Static ssize_t call_sn7326_write_reg (struct device * dev, struct device_attribute * attr, const char * buf, size_t size) {int reg = 0; int value = 0; sscanf (buf, "% d, % x ",®, & Value); sn7326_debug ("sn7326 reg = % d, value = % d \ n", reg, value); if (reg <= 7) & (control_chip_external! = NULL) round (control_chip_external, reg, value); return size;} // static DEVICE_ATTR (write_sn7326_reg, 0666, NULL, temperature); static DEVICE_ATTR (write_sn7326_reg, 0777, NULL, call_sn7326_write_reg); ret = device_create_file (& client-> dev, & dev_attr_write_sn7326_reg); if (ret) {sn7326_debug ("creat sys file failed. \ n ");}
Sys/class/input/event2/device/write_sn7326_reg will be created, and then read and write operations can be performed with cat and echo.