1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-25 16:13:17 +00:00

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)
This commit is contained in:
Vladimir Kondratyev 2020-12-13 12:37:55 +03:00
parent 9477390796
commit 9be6b22da9
7 changed files with 31 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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>

View File

@ -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>