How to load a kernel module automatically?

Bill Nottingham notting at redhat.com
Fri Apr 13 20:13:16 UTC 2007


Julian Sikorski (belegdol at gmail.com) said: 
> Sounds good. Can you shed some more light?

It was sort of a joke, but if you want uinput to load automatically,
you could add something like the attached. It's a pretty gross layering
violation, though.

If you want to do it directly in udev, instead, something like:

BUS=="usb", SYSFS{idProduct}=="0483", SYSFS{idVendor}=="2016", RUN+="/sbin/modprobe uinput"

in a /etc/udev/rules.d rules file should work.

Bill


-------------- next part --------------
--- linux-2.6.20.noarch/drivers/input/misc/uinput.c.foo	2007-04-13 15:33:56.000000000 -0400
+++ linux-2.6.20.noarch/drivers/input/misc/uinput.c	2007-04-13 15:42:28.000000000 -0400
@@ -32,6 +32,7 @@
 #include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/smp_lock.h>
@@ -39,6 +40,16 @@
 #include <linux/miscdevice.h>
 #include <linux/uinput.h>
 
+#define VENDOR_ID_UPEK	0x0483
+#define PRODUCT_ID_THINKFINGER	0x2016
+
+static struct usb_device_id uinput_table[] = {
+        {USB_DEVICE(VENDOR_ID_UPEK, PRODUCT_ID_THINKFINGER)},
+        {}
+};
+
+MODULE_DEVICE_TABLE(usb, uinput_table);
+
 static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 {
 	struct uinput_device	*udev;


More information about the Fedora-maintainers mailing list