Skip to contentSkip to conversation

Add module autoloading support to input layer

PATCH Vojtech Pavlik 3 participants 4 messages Feb 11, 2005 – Feb 13, 2005 Kernel janitors

lore
Share & tools
lore
#0 lore raw
Quoted 14 lines · Duncan Palmer

Hi Vojtech,

Currently, the input device layer relies on the input event handler modules being loaded manually, and doesn't define any module aliases to support autloading of these from userspace or in-kernel.

The attached patch defines MODULE_ALIAS_INPUT which creates modules aliases of the form input-handler-xxx, where xxx is minor >> 5 (to account for the event handlers working with a range of minor numbers). It also modifies input.c to load missing event handler modules.

Quoted 2 lines

Does this look good to you? If so, will the powers that be on KJ please consider applying?

I think that autoloading is a dead end of getting modules into the kernel. The correct way is from the other side - from device discovery and through hotplug.

So I'll not apply your patch.

Quoted 107 lines

diff -ur linux-2.6.11-rc2-mm1.orig/include/linux/input.h linux-2.6.11-rc2-mm1/include/linux/input.h

include/linux/input.h +3 -0
@@ -1012,5 +1012,8 @@
 
 extern struct class_simple *input_class;
 
+#define MODULE_ALIAS_INPUT(x)  \
+	MODULE_ALIAS("input-handler-" __stringify(x))
+
 #endif
 #endif

diff -ur linux-2.6.11-rc2-mm1.orig/drivers/input/evdev.c linux-2.6.11-rc2-mm1/drivers/input/evdev.c

drivers/input/evdev.c +2 -0
@@ -11,6 +11,7 @@
 #define EVDEV_MINOR_BASE	64
 #define EVDEV_MINORS		32
 #define EVDEV_BUFFER_SIZE	64
+#define EVDEV_HANDLER_ID    2   /* EVDEV_MINOR_BASE >> 5 */
 
 #include <linux/poll.h>
 #include <linux/slab.h>
@@ -487,3 +488,4 @@
 MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
 MODULE_DESCRIPTION("Input driver event char devices");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_INPUT(EVDEV_HANDLER_ID);

diff -ur linux-2.6.11-rc2-mm1.orig/drivers/input/input.c linux-2.6.11-rc2-mm1/drivers/input/input.c

drivers/input/input.c +6 -1
@@ -536,7 +536,12 @@
 	struct file_operations *old_fops, *new_fops = NULL;
 	int err;
 
-	/* No load-on-demand here? */
+	if (!handler)
+	{
+		request_module("input-handler-%d", (int)(iminor(inode) >> 5));
+		/* The module will register itself upon loading */
+		handler = input_table[iminor(inode) >> 5];
+	}
 	if (!handler || !(new_fops = fops_get(handler->fops)))
 		return -ENODEV;
 

diff -ur linux-2.6.11-rc2-mm1.orig/drivers/input/joydev.c linux-2.6.11-rc2-mm1/drivers/input/joydev.c

drivers/input/joydev.c +6 -4
@@ -28,14 +28,16 @@
 #include <linux/device.h>
 #include <linux/devfs_fs_kernel.h>
 
+#define JOYDEV_MINOR_BASE	0
+#define JOYDEV_MINORS		16
+#define JOYDEV_BUFFER_SIZE	64
+#define JOYDEV_HANDLER_ID   0   /* JOYDEV_MINOR_BASE >> 5 */
+
 MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
 MODULE_DESCRIPTION("Joystick device interfaces");
 MODULE_SUPPORTED_DEVICE("input/js");
 MODULE_LICENSE("GPL");
-
-#define JOYDEV_MINOR_BASE	0
-#define JOYDEV_MINORS		16
-#define JOYDEV_BUFFER_SIZE	64
+MODULE_ALIAS_INPUT(JOYDEV_HANDLER_ID);
 
 #define MSECS(t)	(1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
 

diff -ur linux-2.6.11-rc2-mm1.orig/drivers/input/mousedev.c linux-2.6.11-rc2-mm1/drivers/input/mousedev.c

drivers/input/mousedev.c +2 -0
@@ -12,6 +12,7 @@
 #define MOUSEDEV_MINOR_BASE 	32
 #define MOUSEDEV_MINORS		32
 #define MOUSEDEV_MIX		31
+#define MOUSEDEV_HANDLER_ID 1       /* MOUSEDEV_MINOR_BASE >> 5 */
 
 #include <linux/slab.h>
 #include <linux/poll.h>
@@ -32,6 +33,7 @@
 MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_INPUT(MOUSEDEV_HANDLER_ID);
 
 #ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_X
 #define CONFIG_INPUT_MOUSEDEV_SCREEN_X	1024

diff -ur linux-2.6.11-rc2-mm1.orig/drivers/input/tsdev.c linux-2.6.11-rc2-mm1/drivers/input/tsdev.c

drivers/input/tsdev.c +2 -0
@@ -40,6 +40,7 @@
 /* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */
 #define TSDEV_MINOR_MASK	15
 #define TSDEV_BUFFER_SIZE	64
+#define TSDEV_HANDLER_ID    4   /* TSDEV_MINOR_BASE >> 5 */
 
 #include <linux/slab.h>
 #include <linux/poll.h>
@@ -82,6 +83,7 @@
 MODULE_AUTHOR("James Simmons <[email protected]>");
 MODULE_DESCRIPTION("Input driver to touchscreen converter");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_INPUT(TSDEV_HANDLER_ID);
 
 static int xres = CONFIG_INPUT_TSDEV_SCREEN_X;
 module_param(xres, uint, 0);
Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 15 lines · On Fri, 11 Feb 2005 08:40:26 +0100 Vojtech Pavlik <[email protected]> wrote:
Quoted 14 lines · Duncan Palmer

Hi Vojtech,

Currently, the input device layer relies on the input event handler modules being loaded manually, and doesn't define any module aliases to support autloading of these from userspace or in-kernel.

The attached patch defines MODULE_ALIAS_INPUT which creates modules aliases of the form input-handler-xxx, where xxx is minor >> 5 (to account for the event handlers working with a range of minor numbers). It also modifies input.c to load missing event handler modules.

Quoted 8 lines
Quoted 2 lines

Does this look good to you? If so, will the powers that be on KJ please consider applying?

I think that autoloading is a dead end of getting modules into the kernel. The correct way is from the other side - from device discovery and through hotplug.

So I'll not apply your patch.

There are two parts here: one is adding the aliases and the other is the auto loading. The aliases are a good idea even without the auto loading because it separates the definition from the implementation and simplifies the hotplug handling.

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to Vojtech Pavlik
Quoted 25 lines · Stephen Hemminger
Quoted 22 lines · On Fri, 11 Feb 2005 08:40:26 +0100 Vojtech Pavlik <[email protected]> wrote:
Quoted 14 lines · Duncan Palmer

Hi Vojtech,

Currently, the input device layer relies on the input event handler modules being loaded manually, and doesn't define any module aliases to support autloading of these from userspace or in-kernel.

The attached patch defines MODULE_ALIAS_INPUT which creates modules aliases of the form input-handler-xxx, where xxx is minor >> 5 (to account for the event handlers working with a range of minor numbers). It also modifies input.c to load missing event handler modules.

Quoted 2 lines

Does this look good to you? If so, will the powers that be on KJ please consider applying?

I think that autoloading is a dead end of getting modules into the kernel. The correct way is from the other side - from device discovery and through hotplug.

Quoted 6 lines
Quoted 1 line

So I'll not apply your patch.

There are two parts here: one is adding the aliases and the other is the auto loading. The aliases are a good idea even without the auto loading because it separates the definition from the implementation and simplifies the hotplug handling.

However, hotplug doesn't load the handler modules by module name or module handler device node number. It loads based on module table bitmaps that either do or don't match a specific input device.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw
In reply to Vojtech Pavlik
Quoted 9 lines · --- Vojtech Pavlik
Quoted 1 line · Stephen Hemminger

There are two parts here: one is adding the

aliases and the other

Quoted 1 line

is the auto loading. The aliases are a good idea

even without the auto loading

Quoted 1 line

because it separates the definition from the

implementation and simplifies

Quoted 9 lines
Quoted 1 line

the hotplug handling.

However, hotplug doesn't load the handler modules by module name or
module handler device node number. It loads based on module table
bitmaps that either do or don't match a specific input device.

Sorry, my mistake. I'd somehow convinced myself that the bitmap was used for mapping which event handlers handled events from which input device drivers (correct), and for telling hotplug which input device drivers, as opposed to event handlers, to load (not correct). Not sure how I managed that...

It may be useful to have aliases for the input device drivers as they currently have none, and some at least rely on aliases defined under /etc/modprobe.d/ for module loading. However, I imagine loading of input event drivers is handled in different ways depending on whether or not they can be detected and what susbsystem does the detecting (for example hotplug figures out it needs to load psmouse by looking at entries under /sys/bus/pnp/devices/). So, this makes it a bit difficult to define alias names that are useful...

Dunk

__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors