#include <linux/atomic.h>
#include <linux/compat.h>
#include <linux/cred.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/hid.h>
#include <linux/input.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/uhid.h>
#include <linux/wait.h>
#define UHID_NAME …
#define UHID_BUFSIZE …
struct uhid_device { … };
static struct miscdevice uhid_misc;
static void uhid_device_add_worker(struct work_struct *work)
{ … }
static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev)
{ … }
static int uhid_queue_event(struct uhid_device *uhid, __u32 event)
{ … }
static int uhid_hid_start(struct hid_device *hid)
{ … }
static void uhid_hid_stop(struct hid_device *hid)
{ … }
static int uhid_hid_open(struct hid_device *hid)
{ … }
static void uhid_hid_close(struct hid_device *hid)
{ … }
static int uhid_hid_parse(struct hid_device *hid)
{ … }
static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
struct uhid_event *ev,
__u32 *report_id)
{ … }
static void uhid_report_wake_up(struct uhid_device *uhid, u32 id,
const struct uhid_event *ev)
{ … }
static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
u8 *buf, size_t count, u8 rtype)
{ … }
static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
const u8 *buf, size_t count, u8 rtype)
{ … }
static int uhid_hid_raw_request(struct hid_device *hid, unsigned char reportnum,
__u8 *buf, size_t len, unsigned char rtype,
int reqtype)
{ … }
static int uhid_hid_output_raw(struct hid_device *hid, __u8 *buf, size_t count,
unsigned char report_type)
{ … }
static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
size_t count)
{ … }
static const struct hid_ll_driver uhid_hid_driver = …;
#ifdef CONFIG_COMPAT
struct uhid_create_req_compat { … } __attribute__((packed));
static int uhid_event_from_user(const char __user *buffer, size_t len,
struct uhid_event *event)
{ … }
#else
static int uhid_event_from_user(const char __user *buffer, size_t len,
struct uhid_event *event)
{
if (copy_from_user(event, buffer, min(len, sizeof(*event))))
return -EFAULT;
return 0;
}
#endif
static int uhid_dev_create2(struct uhid_device *uhid,
const struct uhid_event *ev)
{ … }
static int uhid_dev_create(struct uhid_device *uhid,
struct uhid_event *ev)
{ … }
static int uhid_dev_destroy(struct uhid_device *uhid)
{ … }
static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
{ … }
static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
{ … }
static int uhid_dev_get_report_reply(struct uhid_device *uhid,
struct uhid_event *ev)
{ … }
static int uhid_dev_set_report_reply(struct uhid_device *uhid,
struct uhid_event *ev)
{ … }
static int uhid_char_open(struct inode *inode, struct file *file)
{ … }
static int uhid_char_release(struct inode *inode, struct file *file)
{ … }
static ssize_t uhid_char_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos)
{ … }
static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{ … }
static __poll_t uhid_char_poll(struct file *file, poll_table *wait)
{ … }
static const struct file_operations uhid_fops = …;
static struct miscdevice uhid_misc = …;
module_misc_device(…);
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_ALIAS_MISCDEV(…);
MODULE_ALIAS(…) …;