// SPDX-License-Identifier: GPL-2.0+
/*
* f_hid.c -- USB HID function driver
*
* Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com>
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/hid.h>
#include <linux/idr.h>
#include <linux/cdev.h>
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/workqueue.h>
#include <linux/usb/func_utils.h>
#include <linux/usb/g_hid.h>
#include <uapi/linux/usb/g_hid.h>
#include "u_hid.h"
#define HIDG_MINORS 4
/*
* Most operating systems seem to allow for 5000ms timeout, we will allow
* userspace half that time to respond before we return an empty report.
*/
#define GET_REPORT_TIMEOUT_MS 2500
static int major, minors;
static const struct class hidg_class = {
.name = "hidg",
};
static DEFINE_IDA(hidg_ida);
static DEFINE_MUTEX(hidg_ida_lock); /* protects access to hidg_ida */
struct report_entry {
struct usb_hidg_report report_data;
struct list_he
|