Linux Kernel input设备之handle注册

来源:互联网 发布:python 2能装xgboost吗 编辑:程序博客网 时间:2024/04/27 10:19
/** * input_register_handle - register a new input handle * @handle: handle to register * * This function puts a new input handle onto device's * and handler's lists so that events can flow through * it once it is opened using input_open_device(). * * This function is supposed to be called from handler's * connect() method. */int input_register_handle(struct input_handle *handle){struct input_handler *handler = handle->handler;struct input_dev *dev = handle->dev;int error;/* * We take dev->mutex here to prevent race with * input_release_device(). */error = mutex_lock_interruptible(&dev->mutex);if (error)return error;/* * Filters go to the head of the list, normal handlers * to the tail. */if (handler->filter)list_add_rcu(&handle->d_node, &dev->h_list);elselist_add_tail_rcu(&handle->d_node, &dev->h_list);mutex_unlock(&dev->mutex);/* * Since we are supposed to be called from ->connect() * which is mutually exclusive with ->disconnect() * we can't be racing with input_unregister_handle() * and so separate lock is not needed here. */list_add_tail_rcu(&handle->h_node, &handler->h_list);if (handler->start)handler->start(handle);return 0;}
                                             
0 0