Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  HID support for Linux
0004  *
0005  *  Copyright (c) 1999 Andreas Gal
0006  *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
0007  *  Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
0008  *  Copyright (c) 2007-2008 Oliver Neukum
0009  *  Copyright (c) 2006-2012 Jiri Kosina
0010  *  Copyright (c) 2012 Henrik Rydberg
0011  */
0012 
0013 /*
0014  */
0015 
0016 #include <linux/module.h>
0017 #include <linux/slab.h>
0018 #include <linux/kernel.h>
0019 #include <asm/unaligned.h>
0020 #include <asm/byteorder.h>
0021 
0022 #include <linux/hid.h>
0023 
0024 static struct hid_driver hid_generic;
0025 
0026 static int __check_hid_generic(struct device_driver *drv, void *data)
0027 {
0028     struct hid_driver *hdrv = to_hid_driver(drv);
0029     struct hid_device *hdev = data;
0030 
0031     if (hdrv == &hid_generic)
0032         return 0;
0033 
0034     return hid_match_device(hdev, hdrv) != NULL;
0035 }
0036 
0037 static bool hid_generic_match(struct hid_device *hdev,
0038                   bool ignore_special_driver)
0039 {
0040     if (ignore_special_driver)
0041         return true;
0042 
0043     if (hdev->quirks & HID_QUIRK_HAVE_SPECIAL_DRIVER)
0044         return false;
0045 
0046     /*
0047      * If any other driver wants the device, leave the device to this other
0048      * driver.
0049      */
0050     if (bus_for_each_drv(&hid_bus_type, NULL, hdev, __check_hid_generic))
0051         return false;
0052 
0053     return true;
0054 }
0055 
0056 static int hid_generic_probe(struct hid_device *hdev,
0057                  const struct hid_device_id *id)
0058 {
0059     int ret;
0060 
0061     hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
0062 
0063     ret = hid_parse(hdev);
0064     if (ret)
0065         return ret;
0066 
0067     return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
0068 }
0069 
0070 static const struct hid_device_id hid_table[] = {
0071     { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, HID_ANY_ID, HID_ANY_ID) },
0072     { }
0073 };
0074 MODULE_DEVICE_TABLE(hid, hid_table);
0075 
0076 static struct hid_driver hid_generic = {
0077     .name = "hid-generic",
0078     .id_table = hid_table,
0079     .match = hid_generic_match,
0080     .probe = hid_generic_probe,
0081 };
0082 module_hid_driver(hid_generic);
0083 
0084 MODULE_AUTHOR("Henrik Rydberg");
0085 MODULE_DESCRIPTION("HID generic driver");
0086 MODULE_LICENSE("GPL");