git: cded1fdb3763 - main - hidmap: Implement forbidden flag for hidmap item.

Vladimir Kondratyev wulf at FreeBSD.org
Thu Sep 2 19:35:59 UTC 2021


The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=cded1fdb3763ba1f0f3663e605a5e63089dc8e22

commit cded1fdb3763ba1f0f3663e605a5e63089dc8e22
Author:     Vladimir Kondratyev <wulf at FreeBSD.org>
AuthorDate: 2021-09-02 19:31:51 +0000
Commit:     Vladimir Kondratyev <wulf at FreeBSD.org>
CommitDate: 2021-09-02 19:35:27 +0000

    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(-)

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)				\


More information about the dev-commits-src-main mailing list