Skip to content

Commit fc2237a

Browse files
jigpuJiri Kosina
authored andcommitted
HID: introduce hid_is_using_ll_driver
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>
1 parent bc35f73 commit fc2237a

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

drivers/hid/i2c-hid/i2c-hid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ static int i2c_hid_power(struct hid_device *hid, int lvl)
780780
return 0;
781781
}
782782

783-
static struct hid_ll_driver i2c_hid_ll_driver = {
783+
struct hid_ll_driver i2c_hid_ll_driver = {
784784
.parse = i2c_hid_parse,
785785
.start = i2c_hid_start,
786786
.stop = i2c_hid_stop,
@@ -790,6 +790,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = {
790790
.output_report = i2c_hid_output_report,
791791
.raw_request = i2c_hid_raw_request,
792792
};
793+
EXPORT_SYMBOL_GPL(i2c_hid_ll_driver);
793794

794795
static int i2c_hid_init_irq(struct i2c_client *client)
795796
{

drivers/hid/uhid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
369369
return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT);
370370
}
371371

372-
static struct hid_ll_driver uhid_hid_driver = {
372+
struct hid_ll_driver uhid_hid_driver = {
373373
.start = uhid_hid_start,
374374
.stop = uhid_hid_stop,
375375
.open = uhid_hid_open,
@@ -378,6 +378,7 @@ static struct hid_ll_driver uhid_hid_driver = {
378378
.raw_request = uhid_hid_raw_request,
379379
.output_report = uhid_hid_output_report,
380380
};
381+
EXPORT_SYMBOL_GPL(uhid_hid_driver);
381382

382383
#ifdef CONFIG_COMPAT
383384

drivers/hid/usbhid/hid-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle,
12611261
return hid_set_idle(dev, ifnum, report, idle);
12621262
}
12631263

1264-
static struct hid_ll_driver usb_hid_driver = {
1264+
struct hid_ll_driver usb_hid_driver = {
12651265
.parse = usbhid_parse,
12661266
.start = usbhid_start,
12671267
.stop = usbhid_stop,
@@ -1274,6 +1274,7 @@ static struct hid_ll_driver usb_hid_driver = {
12741274
.output_report = usbhid_output_report,
12751275
.idle = usbhid_idle,
12761276
};
1277+
EXPORT_SYMBOL_GPL(usb_hid_driver);
12771278

12781279
static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id)
12791280
{

include/linux/hid.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,17 @@ struct hid_ll_driver {
777777
int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
778778
};
779779

780+
extern struct hid_ll_driver i2c_hid_ll_driver;
781+
extern struct hid_ll_driver hidp_hid_driver;
782+
extern struct hid_ll_driver uhid_hid_driver;
783+
extern struct hid_ll_driver usb_hid_driver;
784+
785+
static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
786+
struct hid_ll_driver *driver)
787+
{
788+
return hdev->ll_driver == driver;
789+
}
790+
780791
#define PM_HINT_FULLON 1<<5
781792
#define PM_HINT_NORMAL 1<<1
782793

net/bluetooth/hidp/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ static void hidp_stop(struct hid_device *hid)
734734
hid->claimed = 0;
735735
}
736736

737-
static struct hid_ll_driver hidp_hid_driver = {
737+
struct hid_ll_driver hidp_hid_driver = {
738738
.parse = hidp_parse,
739739
.start = hidp_start,
740740
.stop = hidp_stop,
@@ -743,6 +743,7 @@ static struct hid_ll_driver hidp_hid_driver = {
743743
.raw_request = hidp_raw_request,
744744
.output_report = hidp_output_report,
745745
};
746+
EXPORT_SYMBOL_GPL(hidp_hid_driver);
746747

747748
/* This function sets up the hid device. It does not add it
748749
to the HID system. That is done in hidp_add_connection(). */

0 commit comments

Comments
 (0)