自己的备忘记录 : 2012/03/15
{
int ret;
cyttsp_info("Cypress TrueTouch(R) Standard Product\n");
cyttsp_info("I2C Touchscreen Driver (Built %s @ %s)\n", \
__DATE__, __TIME__);
cyttsp_ts_wq = create_singlethread_workqueue("cyttsp_ts_wq");
/*
create_workqueue 用于创建一个 workqueue 队列,为系统中的每个 CPU 都创建一个内核线程
create_singlethread_workqueue 用于创建 workqueue ,只创建一个内核线程
destroy_workqueue 释放 workqueue 队列
schedule_work 调度执行一个具体的任务,执行的任务将会被挂入 Linux 系统提供的 workqueue —— keventd_wq
schedule_delayed_work 延迟一定时间去执行一个具体的任务,功能与 schedule_work 类似,多了一个延迟时间
*/
cyttsp_debug("No memory for cyttsp_ts_wq\n");
return -ENOMEM;
}
ret = i2c_add_driver(&cyttsp_driver); //添加I2C驱动
return ret;
}
===================================================
.driver = {
.name = CY_I2C_NAME,
.owner = THIS_MODULE,
.pm = &cyttsp_pm_ops, //电源管理接口
},
.probe = cyttsp_probe,
.remove = __devexit_p(cyttsp_remove),
.id_table = cyttsp_id,
};
===================================================
const struct i2c_device_id *id)
{
struct cyttsp *ts;
int error;
int retval = CY_OK;
cyttsp_info("Start Probe 1.2\n");
/* allocate and clear memory */
ts = kzalloc(sizeof(struct cyttsp), GFP_KERNEL);
if (ts == NULL) {
cyttsp_xdebug1("err kzalloc for cyttsp\n");
retval = -ENOMEM;
}
//前面有觉得奇怪,在cyttsp_driver中
----------------------
.driver = {
.name = CY_I2C_NAME,
.owner = THIS_MODULE,
.pm = &cyttsp_pm_ops, // 为什么是用这个
},
// .suspend = xxx_suspend, //而不是用这两个,这之间有什么区别
// .resume = xxx_resume,
.remove = __devexit_p(cyttsp_remove),
.id_table = cyttsp_id,
};
------------------------
// 到这里差不多明白了
.suspend = xxx_suspend,
.resume = xxx_resume,
//是系统的睡眠唤醒接口,是不可控的,也就是说:在整个系统睡眠和唤醒时会自动掉用,