Skip to content

Commit 54e4243

Browse files
David Herrmanngregkh
authored andcommitted
HID: uhid: allocate static minor
commit 19872d2 upstream. 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 <kay.sievers@vrfy.org> 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 <teg@jklm.no> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9dfe194 commit 54e4243

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/hid/uhid.c‎

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

641641
static struct miscdevice uhid_misc = {
642642
.fops = &uhid_fops,
643-
.minor = MISC_DYNAMIC_MINOR,
643+
.minor = UHID_MINOR,
644644
.name = UHID_NAME,
645645
};
646646

@@ -659,4 +659,5 @@ module_exit(uhid_exit);
659659
MODULE_LICENSE("GPL");
660660
MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
661661
MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem");
662+
MODULE_ALIAS_MISCDEV(UHID_MINOR);
662663
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)