Skip to content

Commit 19872d2

Browse files
David HerrmannJiri Kosina
authored andcommitted
HID: uhid: allocate static minor
udev has this nice feature of creating "dead" /dev/<node> device-nodes if it finds a devnode:<node> modalias. Once the node is accessed, the kernel automatically loads the module that provides the node. However, this requires udev to know the major:minor code to use for the node. This feature was introduced by: commit 578454f Author: Kay Sievers <[email protected]> Date: Thu May 20 18:07:20 2010 +0200 driver core: add devname module aliases to allow module on-demand auto-loading However, uhid uses dynamic minor numbers so this doesn't actually work. We need to load uhid to know which minor it's going to use. Hence, allocate a static minor (just like uinput does) and we're good to go. Reported-by: Tom Gundersen <[email protected]> Signed-off-by: David Herrmann <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 84fca9f commit 19872d2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

drivers/hid/uhid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static const struct file_operations uhid_fops = {
615615

616616
static struct miscdevice uhid_misc = {
617617
.fops = &uhid_fops,
618-
.minor = MISC_DYNAMIC_MINOR,
618+
.minor = UHID_MINOR,
619619
.name = UHID_NAME,
620620
};
621621

@@ -634,4 +634,5 @@ module_exit(uhid_exit);
634634
MODULE_LICENSE("GPL");
635635
MODULE_AUTHOR("David Herrmann <[email protected]>");
636636
MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem");
637+
MODULE_ALIAS_MISCDEV(UHID_MINOR);
637638
MODULE_ALIAS("devname:" UHID_NAME);

include/linux/miscdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define MAPPER_CTRL_MINOR 236
4646
#define LOOP_CTRL_MINOR 237
4747
#define VHOST_NET_MINOR 238
48+
#define UHID_MINOR 239
4849
#define MISC_DYNAMIC_MINOR 255
4950

5051
struct device;

0 commit comments

Comments
 (0)