]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
HID: introduce hid_is_using_ll_driver
authorJason Gerecke <killertofu@gmail.com>
Mon, 24 Jul 2017 16:46:18 +0000 (09:46 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:03:48 +0000 (10:03 +0100)
commit fc2237a724a9e448599076d7d23497f51e2f7441 upstream.

Although HID itself is transport-agnostic, occasionally a driver may
want to interact with the low-level transport that a device is connected
through. To do this, we need to know what kind of bus is in use. The
first guess may be to look at the 'bus' field of the 'struct hid_device',
but this field may be emulated in some cases (e.g. uhid).

More ideally, we can check which ll_driver a device is using. This
function introduces a 'hid_is_using_ll_driver' function and makes the
'struct hid_ll_driver' of the four most common transports accessible
through hid.h.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/i2c-hid/i2c-hid.c
drivers/hid/uhid.c
drivers/hid/usbhid/hid-core.c
include/linux/hid.h
net/bluetooth/hidp/core.c

index 4248d253c32adec48c1cfcb9647ac1bf93e5ab8d..bd087e849090b41c21badf4712005c349e2cfe5e 100644 (file)
@@ -789,7 +789,7 @@ static int i2c_hid_power(struct hid_device *hid, int lvl)
        return 0;
 }
 
-static struct hid_ll_driver i2c_hid_ll_driver = {
+struct hid_ll_driver i2c_hid_ll_driver = {
        .parse = i2c_hid_parse,
        .start = i2c_hid_start,
        .stop = i2c_hid_stop,
@@ -799,6 +799,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = {
        .output_report = i2c_hid_output_report,
        .raw_request = i2c_hid_raw_request,
 };
+EXPORT_SYMBOL_GPL(i2c_hid_ll_driver);
 
 static int i2c_hid_init_irq(struct i2c_client *client)
 {
index a7ba4db8cff729417552c98ac79b8d705bccddc1..cbcaf5e8c624aca7af3c1967d2e89bf5fa10ac4a 100644 (file)
@@ -372,7 +372,7 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
        return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT);
 }
 
-static struct hid_ll_driver uhid_hid_driver = {
+struct hid_ll_driver uhid_hid_driver = {
        .start = uhid_hid_start,
        .stop = uhid_hid_stop,
        .open = uhid_hid_open,
@@ -381,6 +381,7 @@ static struct hid_ll_driver uhid_hid_driver = {
        .raw_request = uhid_hid_raw_request,
        .output_report = uhid_hid_output_report,
 };
+EXPORT_SYMBOL_GPL(uhid_hid_driver);
 
 #ifdef CONFIG_COMPAT
 
index c7da6ec4d923dc0398b59ccfe85857509b51d0b1..90f6aa9d5eb3e412f87cffba798f8cfc6d5a1ebd 100644 (file)
@@ -1272,7 +1272,7 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle,
        return hid_set_idle(dev, ifnum, report, idle);
 }
 
-static struct hid_ll_driver usb_hid_driver = {
+struct hid_ll_driver usb_hid_driver = {
        .parse = usbhid_parse,
        .start = usbhid_start,
        .stop = usbhid_stop,
@@ -1285,6 +1285,7 @@ static struct hid_ll_driver usb_hid_driver = {
        .output_report = usbhid_output_report,
        .idle = usbhid_idle,
 };
+EXPORT_SYMBOL_GPL(usb_hid_driver);
 
 static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
index 6adea5a39724515b945bf874ab54c2db93bb34a6..9f752e0208e1380390b3ae6b50cbbb28ef92a98a 100644 (file)
@@ -754,6 +754,17 @@ struct hid_ll_driver {
        int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
 };
 
+extern struct hid_ll_driver i2c_hid_ll_driver;
+extern struct hid_ll_driver hidp_hid_driver;
+extern struct hid_ll_driver uhid_hid_driver;
+extern struct hid_ll_driver usb_hid_driver;
+
+static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
+               struct hid_ll_driver *driver)
+{
+       return hdev->ll_driver == driver;
+}
+
 #define        PM_HINT_FULLON  1<<5
 #define PM_HINT_NORMAL 1<<1
 
index 9ec37c6c8c4aa33b868bbebea2ff8e86690f1390..00f25e54119cfd21d06eda30f26bce571efd892c 100644 (file)
@@ -734,7 +734,7 @@ static void hidp_stop(struct hid_device *hid)
        hid->claimed = 0;
 }
 
-static struct hid_ll_driver hidp_hid_driver = {
+struct hid_ll_driver hidp_hid_driver = {
        .parse = hidp_parse,
        .start = hidp_start,
        .stop = hidp_stop,
@@ -743,6 +743,7 @@ static struct hid_ll_driver hidp_hid_driver = {
        .raw_request = hidp_raw_request,
        .output_report = hidp_output_report,
 };
+EXPORT_SYMBOL_GPL(hidp_hid_driver);
 
 /* This function sets up the hid device. It does not add it
    to the HID system. That is done in hidp_add_connection(). */