浅析/dev/input/下major主设备号13鼠标键盘字符设备根据minor匹配上的内核驱动
drivers/input/input.c|1643| err = register_chrdev(INPUT_MAJOR, "input", &input_fops); // 对应/dev/input/下所有major号为13的设备
static const struct file_operations input_fops = {
.owner = THIS_MODULE,
.open = input_open_file, // 只有1个open函数,他将根据minor查找input_table[]驱动
};
对于mouse设备
drivers/input/mousedev.c|1072| error = input_register_handler(&mousedev_handler);
mousedev_init
==> input_register_handler(&mousedev_handler); // 32个minor为一组,由一个handler驱动[luther.gliethttp].
#define MOUSEDEV_MINOR_BASE 32
static struct input_handler mousedev_handler = {
.event = mousedev_event,
.connect = mousedev_connect,
.disconnect = mousedev_disconnect,
.fops = &mousedev_fops,
.minor = MOUSEDEV_MINOR_BASE, // minor等于32-64的/dev/input/节点由mousedev_fops方法管理
.name = "mousedev",
.id_table = mousedev_ids,
};
static const struct file_operations mousedev_fops = {
.owner = THIS_MODULE,
.read = mousedev_read,
.write = mousedev_write,
.poll = mousedev_poll,
.open = mousedev_open,
.release = mousedev_release,
.fasync = mousedev_fasync,
};
对于键盘设备
drivers/input/evdev.c|995| return input_register_handler(&evdev_handler);
evdev_init
==> input_register_handler(&evdev_handler);
#define EVDEV_MINOR_BASE 64 // 32个minor为一组,由一个handler驱动[luther.gliethttp].
static struct input_handler evdev_handler = {
.event = evdev_event,
.connect = evdev_connect,
.disconnect = evdev_disconnect,
.fops = &evdev_fops,
.minor = EVDEV_MINOR_BASE, // minor等于64-96的/dev/input/节点由evdev_fops方法管理
.name = "evdev",
.id_table = evdev_ids,
};
static const struct file_operations evdev_fops = {
.owner = THIS_MODULE,
.read = evdev_read,
.write = evdev_write,
.poll = evdev_poll,
.open = evdev_open,
.release = evdev_release,
.unlocked_ioctl = evdev_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = evdev_ioctl_compat,
#endif
.fasync = evdev_fasync,
.flush = evdev_flush
};
阅读(2182) | 评论(0) | 转发(0) |