[英]Linux Device Driver
我对模块是否正确安装/初始化有疑问,但驱动程序的其他部分未安装或未在输出中显示。
static struct i2c_driver qt2120_dev {
.probe = qt2120_probe,
.remove = qt2120_remove,
.owner = {
.name = qt2120,
.module = THIS_MODULE,
}
....
}
static __init qt2120_init(){
prink("********init******");
.......
}
module_init(qt2120_init)
static int qt2120_probe(){
prink("********probe******");
.......
}
static __devinit qt2120_remove(){
prink("********probe******");
.......
}
输出中仅显示“ / * * init * ”。 根据输出,模块已安装到i2c。
"bus: i2c. qt2120 as qt2120/input"
模块出了点问题,因为printk一直在探针中,根本不会被取出。
我还用qt2120.o作为模块在MAKEFILE @ CONFIG_AT2120 + = qt2160.o中进行了更改
我的配置有问题吗? 在代码aurora中,qt2120.c与qt2160.c非常相似。
由于尚未向i2c子系统注册驱动程序,因此未调用探测和删除功能。 使用i2c_add_driver()API注册驱动程序。 就你而言
static int __init qt2120_init(void)
{
return i2c_add_driver(&qt2120_dev);
}
static void __exit qt2120_remove(void)
{
return i2c_del_driver(&qt2120_dev);
}
首先,您需要使用i2c_add_driver(addr_of_struct i2c_driver)
使I2C驱动程序向I2C内核注册“ struct i2c_driver”结构。
static const struct i2c_device_id sample_i2c_id[] = { { "qt2120", 0 }, { } }; static struct i2c_driver qt2120_dev = { .probe = qt2120_probe, .remove = qt2120_remove, .id_table = sample_i2c_id, .driver = { .name = "qt2120", }, .... };
.id_table
条目。 id_table成员允许我们告诉框架我们支持哪些I2C从属芯片。 匹配.id_table条目后,驱动程序调用探测函数。
使用以下链接作为参考:
了解i2c驱动程序 : http : //www.embedded-bits.co.uk/2009/i2c-in-the-2632-linux-kernel/
示例代码 : https : //code.google.com/p/ldd-templates/source/browse/drivers/i2c/sample-i2c-client.c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.