new style 的I2C设备驱动-----probe不能执行解决方法

//如果i2c_driver ,i2c_device匹配成功,将会执行probe,i2c_device的注册代码在另外的文件中。static int multi_touch_xx_probe(struct i2c_client *client,const struct i2c_device_id *id){printk("***********************/n");printk("***multi_touch_xx_probe***/n");printk("***********************/n"); return 0;}static int __devexit multi_touch_xx_remove(struct i2c_client *client){printk("***********************/n");printk("***multi_touch_xx_remove***/n");printk("***********************/n"); return 0;}static const struct i2c_device_id multi_touch_xx_id[]={{"multi_touch_xx",0},{}};static struct i2c_driver multi_touch_xx_driver = {.driver = {.name = "multi_touch_xx",.owner = THIS_MODULE,},.probe = multi_touch_xx_probe,.remove = __devexit_p(multi_touch_xx_remove),.id_table = multi_touch_xx_id,};static int __init multi_touch_xx_init(void){printk("***********************/n");printk("***multi_touch_xx_init***/n");printk("***********************/n");return i2c_add_driver(&multi_touch_xx_driver);}static void __exit multi_touch_xx_exit(void){printk("***********************/n");printk("***multi_touch_xx_exit***/n");printk("***********************/n");i2c_del_driver(&multi_touch_xx_driver);}module_init(multi_touch_xx_init);module_exit(multi_touch_xx_exit); 


i2c_device的注册代码,可以在内核源码中的搜索相应的代码。

static const struct s35390a_platform_data mma7455l ={ .irq1 = 0, .irq2 = gpio_to_irq(GPIO_NUM(1, 3)),};static const struct s35390a_platform_data multi_touch_xx ={ .irq1 = 1, .irq2 = gpio_to_irq(GPIO_NUM(3, 17)),};static struct i2c_board_info __initdata _i2c[] ={ { I2C_BOARD_INFO("mma7455l", 0x1D), .platform_data = &mma7455l, },{ I2C_BOARD_INFO("multi_touch_xx", 0x60), .platform_data = &multi_touch_xx, },};//在内核源码中的某个文件中的某个函数中:i2c_register_board_info(0, _i2c, ARRAY_SIZE(_i2c)); 

 

你可能感兴趣的:(c,struct,Module,table)