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
1028 if (drvdata->quirks & QUIRK_IS_MULTITOUCH)1028 if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
1029 drvdata->tp = &asus_i2c_tp;1029 drvdata->tp = &asus_i2c_tp;
1030 1030
1031 if ((drvdata->quirks & QUIRK_T100_KEYBOARD) &&1031 if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && hid_is_usb(hdev)) {
1032 hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
1033 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);1032 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
1034 1033
1035 if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) {1034 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
1057 drvdata->tp = &asus_t100chi_tp;1056 drvdata->tp = &asus_t100chi_tp;
1058 }1057 }
1059 1058
1060 if ((drvdata->quirks & QUIRK_MEDION_E1239T) &&1059 if ((drvdata->quirks & QUIRK_MEDION_E1239T) && hid_is_usb(hdev)) {
1061 hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
1062 struct usb_host_interface *alt =1060 struct usb_host_interface *alt =
1063 to_usb_interface(hdev->dev.parent)->altsetting;1061 to_usb_interface(hdev->dev.parent)->altsetting;
1064 1062
drivers/hid/hid-logitech-dj.c+1−1
@@ -1777,7 +1777,7 @@ static int logi_dj_probe(struct hid_device *hdev, · 1776 unmodified lines
1777 case recvr_type_bluetooth: no_dj_interfaces = 2; break;1777 case recvr_type_bluetooth: no_dj_interfaces = 2; break;
1778 case recvr_type_dinovo: no_dj_interfaces = 2; break;1778 case recvr_type_dinovo: no_dj_interfaces = 2; break;
1779 }1779 }
1780 if (hid_is_using_ll_driver(hdev, &usb_hid_driver)) {1780 if (hid_is_usb(hdev)) {
1781 intf = to_usb_interface(hdev->dev.parent);1781 intf = to_usb_interface(hdev->dev.parent);
1782 if (intf && intf->altsetting->desc.bInterfaceNumber >=1782 if (intf && intf->altsetting->desc.bInterfaceNumber >=
1783 no_dj_interfaces) {1783 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
311 unsigned int minor;311 unsigned int minor;
312 int ret;312 int ret;
313 313
314 if (!hid_is_using_ll_driver(hdev, &usb_hid_driver))314 if (!hid_is_usb(hdev))
315 return -EINVAL;315 return -EINVAL;
316 316
317 dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);317 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
843 struct uclogic_params p = {0, };843 struct uclogic_params p = {0, };
844 844
845 /* Check arguments */845 /* Check arguments */
846 if (params == NULL || hdev == NULL ||846 if (params == NULL || hdev == NULL || !hid_is_usb(hdev)) {
847 !hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
848 rc = -EINVAL;847 rc = -EINVAL;
849 goto cleanup;848 goto cleanup;
850 }849 }
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
2214 if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) {2214 if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) {
2215 char *product_name = wacom->hdev->name;2215 char *product_name = wacom->hdev->name;
2216 2216
2217 if (hid_is_using_ll_driver(wacom->hdev, &usb_hid_driver)) {2217 if (hid_is_usb(wacom->hdev)) {
2218 struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent);2218 struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent);
2219 struct usb_device *dev = interface_to_usbdev(intf);2219 struct usb_device *dev = interface_to_usbdev(intf);
2220 product_name = dev->product;2220 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
840 return hdev->ll_driver == driver;840 return hdev->ll_driver == driver;
841}841}
842 842
843static inline bool hid_is_usb(struct hid_device *hdev)
844{
845 return hid_is_using_ll_driver(hdev, &usb_hid_driver);
846}
847
843#define PM_HINT_FULLON 1<<5848#define PM_HINT_FULLON 1<<5
844#define PM_HINT_NORMAL 1<<1849#define PM_HINT_NORMAL 1<<1
845 850