Skip to content

Commit f83baa0

Browse files
gregkhbentiss
authored andcommitted
HID: add hid_is_usb() function to make it simpler for USB detection
A number of HID drivers already call hid_is_using_ll_driver() but only for the detection of if this is a USB device or not. Make this more obvious by creating hid_is_usb() and calling the function that way. Also converts the existing hid_is_using_ll_driver() functions to use the new call. Cc: Jiri Kosina <[email protected]> Cc: Benjamin Tissoires <[email protected]> Cc: [email protected] Cc: [email protected] Tested-by: Benjamin Tissoires <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9003fbe commit f83baa0

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

drivers/hid/hid-asus.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,7 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
10281028
if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
10291029
drvdata->tp = &asus_i2c_tp;
10301030

1031-
if ((drvdata->quirks & QUIRK_T100_KEYBOARD) &&
1032-
hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
1031+
if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && hid_is_usb(hdev)) {
10331032
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
10341033

10351034
if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) {
@@ -1057,8 +1056,7 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
10571056
drvdata->tp = &asus_t100chi_tp;
10581057
}
10591058

1060-
if ((drvdata->quirks & QUIRK_MEDION_E1239T) &&
1061-
hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
1059+
if ((drvdata->quirks & QUIRK_MEDION_E1239T) && hid_is_usb(hdev)) {
10621060
struct usb_host_interface *alt =
10631061
to_usb_interface(hdev->dev.parent)->altsetting;
10641062

drivers/hid/hid-logitech-dj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ static int logi_dj_probe(struct hid_device *hdev,
17771777
case recvr_type_bluetooth: no_dj_interfaces = 2; break;
17781778
case recvr_type_dinovo: no_dj_interfaces = 2; break;
17791779
}
1780-
if (hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
1780+
if (hid_is_usb(hdev)) {
17811781
intf = to_usb_interface(hdev->dev.parent);
17821782
if (intf && intf->altsetting->desc.bInterfaceNumber >=
17831783
no_dj_interfaces) {

drivers/hid/hid-u2fzero.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static int u2fzero_probe(struct hid_device *hdev,
311311
unsigned int minor;
312312
int ret;
313313

314-
if (!hid_is_using_ll_driver(hdev, &usb_hid_driver))
314+
if (!hid_is_usb(hdev))
315315
return -EINVAL;
316316

317317
dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);

drivers/hid/hid-uclogic-params.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,7 @@ int uclogic_params_init(struct uclogic_params *params,
843843
struct uclogic_params p = {0, };
844844

845845
/* Check arguments */
846-
if (params == NULL || hdev == NULL ||
847-
!hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
846+
if (params == NULL || hdev == NULL || !hid_is_usb(hdev)) {
848847
rc = -EINVAL;
849848
goto cleanup;
850849
}

drivers/hid/wacom_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
22142214
if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) {
22152215
char *product_name = wacom->hdev->name;
22162216

2217-
if (hid_is_using_ll_driver(wacom->hdev, &usb_hid_driver)) {
2217+
if (hid_is_usb(wacom->hdev)) {
22182218
struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent);
22192219
struct usb_device *dev = interface_to_usbdev(intf);
22202220
product_name = dev->product;

include/linux/hid.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,11 @@ static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
840840
return hdev->ll_driver == driver;
841841
}
842842

843+
static inline bool hid_is_usb(struct hid_device *hdev)
844+
{
845+
return hid_is_using_ll_driver(hdev, &usb_hid_driver);
846+
}
847+
843848
#define PM_HINT_FULLON 1<<5
844849
#define PM_HINT_NORMAL 1<<1
845850

0 commit comments

Comments
 (0)