key 的poll
2015-06-26 19:37
281 查看
1、文件
/*
* The input core
*input.c
*/
2、fileops
static const struct file_operations input_devices_fileops = {
.owner = THIS_MODULE,
.open = input_proc_devices_open,
.poll = input_proc_devices_poll,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
3、poll
static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
{
poll_wait(file, &input_devices_poll_wait, wait);//等待中断来唤醒
if (file->f_version != input_devices_state) {
file->f_version = input_devices_state;
return POLLIN | POLLRDNORM;//返回
}
return 0;//返回后,应用端调用read。
}
4、wakeup
static inline void input_wakeup_procfs_readers(void)
{
input_devices_state++;
wake_up(&input_devices_poll_wait);//唤醒休眠
}
/**
* input_register_handler - register a new input handler
* @handler: handler to be registered
*
* This function registers a new input handler (interface) for input
* devices in the system and attaches it to all input devices that
* are compatible with the handler.
*/
int input_register_handler(struct input_handler *handler)
{
struct input_dev *dev;
int error;
error = mutex_lock_interruptible(&input_mutex);
if (error)
return error;
INIT_LIST_HEAD(&handler->h_list);
list_add_tail(&handler->node, &input_handler_list);
list_for_each_entry(dev, &input_dev_list, node)
input_attach_handler(dev, handler);
input_wakeup_procfs_readers();
mutex_unlock(&input_mutex);
return 0;
}
EXPORT_SYMBOL(input_register_handler);
5、
/*
* The input core
*input.c
*/
2、fileops
static const struct file_operations input_devices_fileops = {
.owner = THIS_MODULE,
.open = input_proc_devices_open,
.poll = input_proc_devices_poll,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
3、poll
static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
{
poll_wait(file, &input_devices_poll_wait, wait);//等待中断来唤醒
if (file->f_version != input_devices_state) {
file->f_version = input_devices_state;
return POLLIN | POLLRDNORM;//返回
}
return 0;//返回后,应用端调用read。
}
4、wakeup
static inline void input_wakeup_procfs_readers(void)
{
input_devices_state++;
wake_up(&input_devices_poll_wait);//唤醒休眠
}
/**
* input_register_handler - register a new input handler
* @handler: handler to be registered
*
* This function registers a new input handler (interface) for input
* devices in the system and attaches it to all input devices that
* are compatible with the handler.
*/
int input_register_handler(struct input_handler *handler)
{
struct input_dev *dev;
int error;
error = mutex_lock_interruptible(&input_mutex);
if (error)
return error;
INIT_LIST_HEAD(&handler->h_list);
list_add_tail(&handler->node, &input_handler_list);
list_for_each_entry(dev, &input_dev_list, node)
input_attach_handler(dev, handler);
input_wakeup_procfs_readers();
mutex_unlock(&input_mutex);
return 0;
}
EXPORT_SYMBOL(input_register_handler);
5、
相关文章推荐
- 判断一个二叉树是否平衡
- 2015年第十六周oj刷题:复制字符串
- spring 事务详解
- Scala学习(三)----数组相关操作
- leetcode: Minimum Path Sum
- 安装samba服务器实现Linux mint和Windows共享文件
- zlib解压时, 文件夹的判断
- Tomcat部署Web项目方式
- UI中懒加载的使用
- 【学习笔记】【C语言】变量类型
- Java环境变量的配置及自己遇到的问题
- 黑客攻击流程图
- Android GBK与UTF-8
- easyui datagrid 每条数据后添加操作按钮
- Java基础 StringBuilder和StringBuffer的区别
- spring IOC 详解
- Goldengate handlecollisions引起的数据重复
- 中国上网费问题
- 监控系统选型
- Add Two Numbers - C++链表操作