使用官方例程,只能到init,而probe下的内容没有调用到也无法打印。
[root@100ask:~]# insmod ap3216c_drv.ko
[ 7083.698920] /home/book/100ask-dirver/04_ap3216c_ok/ap3216c_drv.c i2c_driver_ap3216c_init 118
static int ap3216c_probe(struct i2c_client *client)
{
printk(“%s %s %d\n”, FILE, FUNCTION, LINE); ------这里没有打印。
ap3216c_client = client;
/* register_chrdev */
major = register_chrdev(0, "ap3216c", &ap3216c_ops);
ap3216c_class = class_create(THIS_MODULE, "ap3216c_class");
device_create(ap3216c_class, NULL, MKDEV(major, 0), NULL, "ap3216c"); /* /dev/ap3216c */
return 0;
}
static int ap3216c_remove(struct i2c_client *client)
{
printk(“%s %s %d\n”, FILE, FUNCTION, LINE);
device_destroy(ap3216c_class, MKDEV(major, 0));
class_destroy(ap3216c_class);
/* unregister_chrdev */
unregister_chrdev(major, "ap3216c");
return 0;
}
static struct i2c_driver i2c_ap3216c_driver = {
.driver = {
.name = “ap3216c”,
.of_match_table = of_match_ids_ap3216c,
},
.probe_new = ap3216c_probe,
.remove = ap3216c_remove,
.id_table = ap3216c_ids,
};
[root@100ask:~]# i2cdetect -y 0 也是有设备的。
装载完驱动,[root@100ask:~]# cat /proc/devices
也没有ap3216c相关内容。