git: 9be6b22da9b2 - main - hidraw(4): Add HIDRAW_MAKE_UHID_ALIAS kernel option
Vladimir Kondratyev
wulf at FreeBSD.org
Thu Jan 7 23:20:51 UTC 2021
The branch main has been updated by wulf:
URL: https://cgit.FreeBSD.org/src/commit/?id=9be6b22da9b2df9903310a307f36f5297b1660b6
commit 9be6b22da9b2df9903310a307f36f5297b1660b6
Author: Vladimir Kondratyev <wulf at FreeBSD.org>
AuthorDate: 2020-12-13 09:37:55 +0000
Commit: Vladimir Kondratyev <wulf at FreeBSD.org>
CommitDate: 2021-01-07 23:18:44 +0000
hidraw(4): Add HIDRAW_MAKE_UHID_ALIAS kernel option
which installs /dev/uhid# alias to hidraw character device for
compatibility with some existing uhid(4) users like Firefox.
As side effect it renames traditional uhid(4) driver to hidraw
to make possible using of common unit number allocator.
Requested by: Greg V <greg_unrelenting.technology>
Reviewed by: hselasky (as part of D27992)
---
sys/conf/options | 1 +
sys/dev/hid/hid.c | 4 ++++
sys/dev/hid/hid.h | 3 +++
sys/dev/hid/hidraw.c | 9 ++++++++-
sys/dev/usb/input/uhid.c | 12 ++++++++++++
sys/modules/hid/hidraw/Makefile | 2 +-
sys/modules/usb/uhid/Makefile | 4 ++--
7 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/sys/conf/options b/sys/conf/options
index 789def58cb48..e69ee92d1136 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -1020,3 +1020,4 @@ HID_DEBUG opt_hid.h
IICHID_DEBUG opt_hid.h
IICHID_SAMPLING opt_hid.h
HKBD_DFLT_KEYMAP opt_hkbd.h
+HIDRAW_MAKE_UHID_ALIAS opt_hid.h
diff --git a/sys/dev/hid/hid.c b/sys/dev/hid/hid.c
index 5a91692e1038..699bfa4a8bb3 100644
--- a/sys/dev/hid/hid.c
+++ b/sys/dev/hid/hid.c
@@ -58,6 +58,10 @@ SYSCTL_NODE(_hw, OID_AUTO, hid, CTLFLAG_RW, 0, "HID debugging");
SYSCTL_INT(_hw_hid, OID_AUTO, debug, CTLFLAG_RWTUN,
&hid_debug, 0, "Debug level");
+#ifdef HIDRAW_MAKE_UHID_ALIAS
+devclass_t hidraw_devclass;
+#endif
+
static void hid_clear_local(struct hid_item *);
static uint8_t hid_get_byte(struct hid_data *s, const uint16_t wSize);
diff --git a/sys/dev/hid/hid.h b/sys/dev/hid/hid.h
index cea33f7b4af8..e88cbba04d9a 100644
--- a/sys/dev/hid/hid.h
+++ b/sys/dev/hid/hid.h
@@ -193,6 +193,9 @@
#define HID_MAX_AUTO_QUIRK 8 /* maximum number of dynamic quirks */
#define HID_PNP_ID_SIZE 20 /* includes null terminator */
+/* Share unit number pool between uhid and hidraw */
+extern devclass_t hidraw_devclass;
+
/* Declare global HID debug variable. */
extern int hid_debug;
diff --git a/sys/dev/hid/hidraw.c b/sys/dev/hid/hidraw.c
index 1da8cb202bd9..6cc67ff14d23 100644
--- a/sys/dev/hid/hidraw.c
+++ b/sys/dev/hid/hidraw.c
@@ -38,6 +38,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_hid.h"
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/conf.h>
@@ -207,6 +209,9 @@ hidraw_attach(device_t self)
hidraw_detach(self);
return (error);
}
+#ifdef HIDRAW_MAKE_UHID_ALIAS
+ (void)make_dev_alias(sc->dev, "uhid%d", device_get_unit(self));
+#endif
hidbus_set_lock(self, &sc->sc_mtx);
hidbus_set_intr(self, hidraw_intr, sc);
@@ -893,7 +898,9 @@ static driver_t hidraw_driver = {
sizeof(struct hidraw_softc)
};
-static devclass_t hidraw_devclass;
+#ifndef HIDRAW_MAKE_UHID_ALIAS
+devclass_t hidraw_devclass;
+#endif
DRIVER_MODULE(hidraw, hidbus, hidraw_driver, hidraw_devclass, NULL, 0);
MODULE_DEPEND(hidraw, hidbus, 1, 1, 1);
diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
index dd463dd7de8c..e5eae534a6d0 100644
--- a/sys/dev/usb/input/uhid.c
+++ b/sys/dev/usb/input/uhid.c
@@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$");
* HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
*/
+#include "opt_hid.h"
+
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@@ -891,7 +893,9 @@ uhid_detach(device_t dev)
return (0);
}
+#ifndef HIDRAW_MAKE_UHID_ALIAS
static devclass_t uhid_devclass;
+#endif
static device_method_t uhid_methods[] = {
DEVMETHOD(device_probe, uhid_probe),
@@ -902,12 +906,20 @@ static device_method_t uhid_methods[] = {
};
static driver_t uhid_driver = {
+#ifdef HIDRAW_MAKE_UHID_ALIAS
+ .name = "hidraw",
+#else
.name = "uhid",
+#endif
.methods = uhid_methods,
.size = sizeof(struct uhid_softc),
};
+#ifdef HIDRAW_MAKE_UHID_ALIAS
+DRIVER_MODULE(uhid, uhub, uhid_driver, hidraw_devclass, NULL, 0);
+#else
DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, NULL, 0);
+#endif
MODULE_DEPEND(uhid, usb, 1, 1, 1);
MODULE_DEPEND(uhid, hid, 1, 1, 1);
MODULE_VERSION(uhid, 1);
diff --git a/sys/modules/hid/hidraw/Makefile b/sys/modules/hid/hidraw/Makefile
index e6305bc5bdb6..fdf9c31c9f3a 100644
--- a/sys/modules/hid/hidraw/Makefile
+++ b/sys/modules/hid/hidraw/Makefile
@@ -4,6 +4,6 @@
KMOD= hidraw
SRCS= hidraw.c
-SRCS+= bus_if.h device_if.h
+SRCS+= opt_hid.h bus_if.h device_if.h
.include <bsd.kmod.mk>
diff --git a/sys/modules/usb/uhid/Makefile b/sys/modules/usb/uhid/Makefile
index f1fa4f660b36..1ae7b012903f 100644
--- a/sys/modules/usb/uhid/Makefile
+++ b/sys/modules/usb/uhid/Makefile
@@ -30,7 +30,7 @@ S= ${SRCTOP}/sys
.PATH: $S/dev/usb/input
KMOD= uhid
-SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \
- uhid.c
+SRCS= opt_bus.h opt_hid.h opt_usb.h device_if.h bus_if.h usb_if.h \
+ vnode_if.h usbdevs.h uhid.c
.include <bsd.kmod.mk>
More information about the dev-commits-src-main
mailing list