# \[PATCH 4.9 02/42\] HID: add hid\_is\_usb() function to make it simpler for USB detection

- Subsystems: HID CORE LAYER, THE REST
- Maintainers: Jiri Kosina, Benjamin Tissoires, Linus Torvalds
- Status: REVIEWED · 1 review, 1 by a maintainer (M Benjamin Tissoires)
- Reviewed.
- 1 review trailer.
- List: linux-input
- 1 message, 1 author
- Page: https://ratatoskr.run/linux-input/2021/12/1605765/t

## \[PATCH 4.9 02/42\] HID: add hid\_is\_usb() function to make it simpler for USB detection

- From: Greg Kroah-Hartman \<gregkh@linuxfoundation.org\>
- Date: 2021-12-13 09:34:58 
- Message: https://ratatoskr.run/linux-input/2021/12/1605765.md

```text
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f83baa0cb6cfc92ebaf7f9d3a99d7e34f2e77a8a upstream.

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 <jikos@kernel.org>
Cc: Benjamin Tissoires <redacted>
Cc: <redacted>
Cc: <redacted>
Tested-by: Benjamin Tissoires <redacted>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Benjamin Tissoires <redacted>
Link: https://lore.kernel.org/r/20211201183503.2373082-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/hid.h |    5 +++++
 1 file changed, 5 insertions(+)

--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -773,6 +773,11 @@ static inline bool hid_is_using_ll_drive
 	return hdev->ll_driver == driver;
 }
 
+static inline bool hid_is_usb(struct hid_device *hdev)
+{
+	return hid_is_using_ll_driver(hdev, &usb_hid_driver);
+}
+
 #define	PM_HINT_FULLON	1<<5
 #define PM_HINT_NORMAL	1<<1
 


```
