您的位置:首页 > 其它

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、
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: