1 From 19872d20c890073c5207d9e02bb8f14d451a11eb Mon Sep 17 00:00:00 2001
2 From: David Herrmann <dh.herrmann@gmail.com>
3 Date: Mon, 9 Sep 2013 18:33:54 +0200
4 Subject: HID: uhid: allocate static minor
6 From: David Herrmann <dh.herrmann@gmail.com>
8 commit 19872d20c890073c5207d9e02bb8f14d451a11eb upstream.
10 udev has this nice feature of creating "dead" /dev/<node> device-nodes if
11 it finds a devnode:<node> modalias. Once the node is accessed, the kernel
12 automatically loads the module that provides the node. However, this
13 requires udev to know the major:minor code to use for the node. This
14 feature was introduced by:
16 commit 578454ff7eab61d13a26b568f99a89a2c9edc881
17 Author: Kay Sievers <kay.sievers@vrfy.org>
18 Date: Thu May 20 18:07:20 2010 +0200
20 driver core: add devname module aliases to allow module on-demand auto-loading
22 However, uhid uses dynamic minor numbers so this doesn't actually work. We
23 need to load uhid to know which minor it's going to use.
25 Hence, allocate a static minor (just like uinput does) and we're good
28 Reported-by: Tom Gundersen <teg@jklm.no>
29 Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
30 Signed-off-by: Jiri Kosina <jkosina@suse.cz>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34 drivers/hid/uhid.c | 3 ++-
35 include/linux/miscdevice.h | 1 +
36 2 files changed, 3 insertions(+), 1 deletion(-)
38 --- a/drivers/hid/uhid.c
39 +++ b/drivers/hid/uhid.c
40 @@ -640,7 +640,7 @@ static const struct file_operations uhid
42 static struct miscdevice uhid_misc = {
44 - .minor = MISC_DYNAMIC_MINOR,
45 + .minor = UHID_MINOR,
49 @@ -659,4 +659,5 @@ module_exit(uhid_exit);
50 MODULE_LICENSE("GPL");
51 MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
52 MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem");
53 +MODULE_ALIAS_MISCDEV(UHID_MINOR);
54 MODULE_ALIAS("devname:" UHID_NAME);
55 --- a/include/linux/miscdevice.h
56 +++ b/include/linux/miscdevice.h
58 #define MAPPER_CTRL_MINOR 236
59 #define LOOP_CTRL_MINOR 237
60 #define VHOST_NET_MINOR 238
61 +#define UHID_MINOR 239
62 #define MISC_DYNAMIC_MINOR 255