From cded1fdb3763ba1f0f3663e605a5e63089dc8e22 Mon Sep 17 00:00:00 2001 From: Vladimir Kondratyev Date: Thu, 2 Sep 2021 22:31:51 +0300 Subject: hidmap: Implement forbidden flag for hidmap item. If HID usage is mapped to evdev event by hidmap item marked with this flag than entire driver attachment is blocked. MFC after: 2 week --- sys/dev/hid/hidmap.c | 5 ++++- sys/dev/hid/hidmap.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/dev/hid') diff --git a/sys/dev/hid/hidmap.c b/sys/dev/hid/hidmap.c index 46e789fa7cec..c46930214323 100644 --- a/sys/dev/hid/hidmap.c +++ b/sys/dev/hid/hidmap.c @@ -481,7 +481,10 @@ hidmap_probe_hid_descr(void *d_ptr, hid_size_t d_len, uint8_t tlc_index, /* Check that all mandatory usages are present in report descriptor */ if (items != 0) { for (i = 0; i < nitems_map; i++) { - if (map[i].required && isclr(caps, i)) { + KASSERT(!(map[i].required && map[i].forbidden), + ("both required & forbidden item flags are set")); + if ((map[i].required && isclr(caps, i)) || + (map[i].forbidden && isset(caps, i))) { items = 0; break; } diff --git a/sys/dev/hid/hidmap.h b/sys/dev/hid/hidmap.h index 6ac23b3dc4ee..f5ce10069e1a 100644 --- a/sys/dev/hid/hidmap.h +++ b/sys/dev/hid/hidmap.h @@ -98,7 +98,8 @@ struct hidmap_item { bool has_cb:1; bool final_cb:1; bool invert_value:1; - u_int reserved:10; + bool forbidden:1; /* Forbidden by driver */ + u_int reserved:9; }; #define HIDMAP_ANY(_page, _usage, _type, _code) \ -- cgit v1.2.3