diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-09-09 12:33:54 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-09-26 05:03:29 -0400 |
commit | 19872d20c890073c5207d9e02bb8f14d451a11eb (patch) | |
tree | 7f83152f8b341304cf4134fe85ab50d349d15ab1 | |
parent | 84fca9f38c5d646e95cdeef70e41cf15db549b95 (diff) |
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 578454ff7eab61d13a26b568f99a89a2c9edc881
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>
-rw-r--r-- | drivers/hid/uhid.c | 3 | ||||
-rw-r--r-- | include/linux/miscdevice.h | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 5bf2fb785844..93b00d76374c 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c | |||
@@ -615,7 +615,7 @@ static const struct file_operations uhid_fops = { | |||
615 | 615 | ||
616 | static struct miscdevice uhid_misc = { | 616 | static struct miscdevice uhid_misc = { |
617 | .fops = &uhid_fops, | 617 | .fops = &uhid_fops, |
618 | .minor = MISC_DYNAMIC_MINOR, | 618 | .minor = UHID_MINOR, |
619 | .name = UHID_NAME, | 619 | .name = UHID_NAME, |
620 | }; | 620 | }; |
621 | 621 | ||
@@ -634,4 +634,5 @@ module_exit(uhid_exit); | |||
634 | MODULE_LICENSE("GPL"); | 634 | MODULE_LICENSE("GPL"); |
635 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); | 635 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); |
636 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); | 636 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); |
637 | MODULE_ALIAS_MISCDEV(UHID_MINOR); | ||
637 | MODULE_ALIAS("devname:" UHID_NAME); | 638 | MODULE_ALIAS("devname:" UHID_NAME); |
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index 09c2300ddb37..cb358355ef43 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h | |||
@@ -45,6 +45,7 @@ | |||
45 | #define MAPPER_CTRL_MINOR 236 | 45 | #define MAPPER_CTRL_MINOR 236 |
46 | #define LOOP_CTRL_MINOR 237 | 46 | #define LOOP_CTRL_MINOR 237 |
47 | #define VHOST_NET_MINOR 238 | 47 | #define VHOST_NET_MINOR 238 |
48 | #define UHID_MINOR 239 | ||
48 | #define MISC_DYNAMIC_MINOR 255 | 49 | #define MISC_DYNAMIC_MINOR 255 |
49 | 50 | ||
50 | struct device; | 51 | struct device; |