diff options
author | Anton Lindqvist <anton@cvs.openbsd.org> | 2021-08-29 18:21:17 +0000 |
---|---|---|
committer | Anton Lindqvist <anton@cvs.openbsd.org> | 2021-08-29 18:21:17 +0000 |
commit | 272143932f5916acd3d828ebb9db926f37834f1f (patch) | |
tree | 4c6df55f5c75827c46d95ca383973643c1111e61 /sys/dev | |
parent | cdd0cde836800e68ad507d78bc9f5be6d72327dd (diff) |
Make the ucc match criteria more stringent by requiring at least one
usage greater than zero. Usage zero is defined as unassigned by the
specification and cannot be mapped to anything sensible.
Prevents ucc from attaching to bunch of odd report IDs from a Lenovo
ThinkPad USB-C Dock which only exposes the unassigned usage. This is
not a problem in practice but I think we're better attaching them as
uhid devices instead as ucc cannot provide any functionality.
Thanks to Mario Peter <mp at mpeter dot de> for reporting and testing.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/ucc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/dev/usb/ucc.c b/sys/dev/usb/ucc.c index d7aba7b5f82..d2b169d03ec 100644 --- a/sys/dev/usb/ucc.c +++ b/sys/dev/usb/ucc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucc.c,v 1.16 2021/08/29 18:20:18 anton Exp $ */ +/* $OpenBSD: ucc.c,v 1.17 2021/08/29 18:21:16 anton Exp $ */ /* * Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org> @@ -839,19 +839,21 @@ ucc_hid_match(void *desc, int descsiz, uint8_t repid) { struct hid_item hi; struct hid_data *hd; - int match = 0; + int32_t maxusage = 0; hd = hid_start_parse(desc, descsiz, hid_input); while (hid_get_item(hd, &hi)) { if (hi.report_ID == repid && hi.kind == hid_input && HID_GET_USAGE_PAGE(hi.usage) == HUP_CONSUMER) { - match = 1; - break; + if (HID_GET_USAGE(hi.usage_maximum) > maxusage) + maxusage = HID_GET_USAGE(hi.usage_maximum); + else if (HID_GET_USAGE(hi.usage) > maxusage) + maxusage = HID_GET_USAGE(hi.usage); } } hid_end_parse(hd); - return match; + return maxusage > 0; } /* |