David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * User-space I/O driver support for HID subsystem |
| 3 | * Copyright (c) 2012 David Herrmann |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/atomic.h> |
| 14 | #include <linux/device.h> |
| 15 | #include <linux/fs.h> |
| 16 | #include <linux/hid.h> |
| 17 | #include <linux/input.h> |
| 18 | #include <linux/miscdevice.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/mutex.h> |
| 21 | #include <linux/poll.h> |
| 22 | #include <linux/sched.h> |
| 23 | #include <linux/spinlock.h> |
| 24 | #include <linux/uhid.h> |
| 25 | #include <linux/wait.h> |
| 26 | |
| 27 | #define UHID_NAME "uhid" |
| 28 | |
| 29 | static struct miscdevice uhid_misc; |
| 30 | |
| 31 | static int uhid_char_open(struct inode *inode, struct file *file) |
| 32 | { |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | static int uhid_char_release(struct inode *inode, struct file *file) |
| 37 | { |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static ssize_t uhid_char_read(struct file *file, char __user *buffer, |
| 42 | size_t count, loff_t *ppos) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static ssize_t uhid_char_write(struct file *file, const char __user *buffer, |
| 48 | size_t count, loff_t *ppos) |
| 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | static unsigned int uhid_char_poll(struct file *file, poll_table *wait) |
| 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static const struct file_operations uhid_fops = { |
| 59 | .owner = THIS_MODULE, |
| 60 | .open = uhid_char_open, |
| 61 | .release = uhid_char_release, |
| 62 | .read = uhid_char_read, |
| 63 | .write = uhid_char_write, |
| 64 | .poll = uhid_char_poll, |
| 65 | .llseek = no_llseek, |
| 66 | }; |
| 67 | |
| 68 | static struct miscdevice uhid_misc = { |
| 69 | .fops = &uhid_fops, |
| 70 | .minor = MISC_DYNAMIC_MINOR, |
| 71 | .name = UHID_NAME, |
| 72 | }; |
| 73 | |
| 74 | static int __init uhid_init(void) |
| 75 | { |
| 76 | return misc_register(&uhid_misc); |
| 77 | } |
| 78 | |
| 79 | static void __exit uhid_exit(void) |
| 80 | { |
| 81 | misc_deregister(&uhid_misc); |
| 82 | } |
| 83 | |
| 84 | module_init(uhid_init); |
| 85 | module_exit(uhid_exit); |
| 86 | MODULE_LICENSE("GPL"); |
| 87 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); |
| 88 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); |