From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Jason Gerecke <jason.gerecke@wacom.com>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 4.9 01/42] HID: introduce hid_is_using_ll_driver
Date: Mon, 13 Dec 2021 10:29:43 +0100 [thread overview]
Message-ID: <20211213092926.625986930@linuxfoundation.org> (raw)
In-Reply-To: <20211213092926.578829548@linuxfoundation.org>
From: Jason Gerecke <killertofu@gmail.com>
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-core.c | 3 ++-
drivers/hid/uhid.c | 3 ++-
drivers/hid/usbhid/hid-core.c | 3 ++-
include/linux/hid.h | 11 +++++++++++
net/bluetooth/hidp/core.c | 3 ++-
5 files changed, 19 insertions(+), 4 deletions(-)
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -875,7 +875,7 @@ static int i2c_hid_power(struct hid_devi
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,
@@ -885,6 +885,7 @@ static struct hid_ll_driver i2c_hid_ll_d
.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)
{
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -372,7 +372,7 @@ static int uhid_hid_output_report(struct
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_dri
.raw_request = uhid_hid_raw_request,
.output_report = uhid_hid_output_report,
};
+EXPORT_SYMBOL_GPL(uhid_hid_driver);
#ifdef CONFIG_COMPAT
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1272,7 +1272,7 @@ static int usbhid_idle(struct hid_device
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_driv
.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)
{
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -762,6 +762,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
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -734,7 +734,7 @@ static void hidp_stop(struct hid_device
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_dri
.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(). */
next prev parent reply other threads:[~2021-12-13 9:34 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-13 9:29 [PATCH 4.9 00/42] 4.9.293-rc1 review Greg Kroah-Hartman
2021-12-13 9:29 ` Greg Kroah-Hartman [this message]
2021-12-13 9:29 ` [PATCH 4.9 02/42] HID: add hid_is_usb() function to make it simpler for USB detection Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 03/42] HID: add USB_HID dependancy to hid-prodikeys Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 04/42] HID: add USB_HID dependancy to hid-chicony Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 05/42] HID: add USB_HID dependancy on some USB HID drivers Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 06/42] HID: wacom: fix problems when device is not a valid USB device Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 07/42] HID: check for valid USB device for many HID drivers Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 08/42] can: sja1000: fix use after free in ems_pcmcia_add_card() Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 09/42] nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 10/42] IB/hfi1: Correct guard on eager buffer deallocation Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 11/42] mm: bdi: initialize bdi_min_ratio when bdi is unregistered Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 12/42] ALSA: ctl: Fix copy of updated id with element read/write Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 13/42] ALSA: pcm: oss: Fix negative period/buffer sizes Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 14/42] ALSA: pcm: oss: Limit the period size to 16MB Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 15/42] ALSA: pcm: oss: Handle missing errors in snd_pcm_oss_change_params*() Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 16/42] tracefs: Have new files inherit the ownership of their parent Greg Kroah-Hartman
2021-12-13 9:29 ` [PATCH 4.9 17/42] can: pch_can: pch_can_rx_normal: fix use after free Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 18/42] libata: add horkage for ASMedia 1092 Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 19/42] wait: add wake_up_pollfree() Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 20/42] binder: use wake_up_pollfree() Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 21/42] signalfd: " Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 22/42] tracefs: Set all files to the same group ownership as the mount option Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 23/42] block: fix ioprio_get(IOPRIO_WHO_PGRP) vs setuid(2) Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 24/42] net: cdc_ncm: Allow for dwNtbOutMaxSize to be unset or zero Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 25/42] net: altera: set a couple error code in probe() Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 26/42] net: fec: only clear interrupt of handling queue in fec_enet_rx_queue() Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 27/42] net, neigh: clear whole pneigh_entry at alloc time Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 28/42] net/qla3xxx: fix an error code in ql_adapter_up() Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 29/42] USB: gadget: detect too-big endpoint 0 requests Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 30/42] USB: gadget: zero allocate endpoint 0 buffers Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 31/42] usb: core: config: fix validation of wMaxPacketValue entries Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 32/42] usb: core: config: using bit mask instead of individual bits Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 33/42] iio: stk3310: Dont return error code in interrupt handler Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 34/42] iio: mma8452: Fix trigger reference couting Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 35/42] iio: ltr501: Dont return error code in trigger handler Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 36/42] iio: kxsd9: " Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 37/42] iio: itg3200: Call iio_trigger_notify_done() on error Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 38/42] iio: accel: kxcjk-1013: Fix possible memory leak in probe and remove Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 39/42] irqchip/armada-370-xp: Fix return value of armada_370_xp_msi_alloc() Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 40/42] irqchip/armada-370-xp: Fix support for Multi-MSI interrupts Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 41/42] irqchip/irq-gic-v3-its.c: Force synchronisation when issuing INVALL Greg Kroah-Hartman
2021-12-13 9:30 ` [PATCH 4.9 42/42] irqchip: nvic: Fix offset for Interrupt Priority Offsets Greg Kroah-Hartman
2021-12-13 19:54 ` [PATCH 4.9 00/42] 4.9.293-rc1 review Guenter Roeck
2021-12-13 20:00 ` Florian Fainelli
2021-12-13 20:31 ` Shuah Khan
2021-12-14 5:53 ` Naresh Kamboju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211213092926.625986930@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=benjamin.tissoires@redhat.com \
--cc=jason.gerecke@wacom.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox