History

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.

Greg Kroah-Hartman committed 4 years ago

Commit f83baa01 parent 9003fbe6 files · +11 −9Browse files

Unified · Split

6 files
  1. drivers/hid/hid-asus.c +2 −4
  2. drivers/hid/hid-logitech-dj.c +1 −1
  3. drivers/hid/hid-u2fzero.c +1 −1
  4. drivers/hid/hid-uclogic-params.c +1 −2
  5. drivers/hid/wacom_sys.c +1 −1
  6. include/linux/hid.h +5 −0
drivers/hid/hid-asus.c+2−4
@@ -1028,8 +1028,7 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) · 1027 unmodified lines
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) · 21 unmodified lines
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+1−1
@@ -1777,7 +1777,7 @@ static int logi_dj_probe(struct hid_device *hdev, · 1776 unmodified lines
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+1−1
@@ -311,7 +311,7 @@ static int u2fzero_probe(struct hid_device *hdev, · 310 unmodified lines
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+1−2
@@ -843,8 +843,7 @@ int uclogic_params_init(struct uclogic_params *params, · 842 unmodified lines
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+1−1
@@ -2214,7 +2214,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix) · 2213 unmodified lines
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+5−0
@@ -840,6 +840,11 @@ static inline bool hid_is_using_ll_driver(struct hid_device *hdev, · 839 unmodified lines
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