HID: add compat support
authorJiri Slaby <jirislaby@gmail.com>
Fri, 16 May 2008 09:49:22 +0000 (11:49 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 14 Oct 2008 21:50:50 +0000 (23:50 +0200)
Add compat option to hid code to allow loading of all modules on
systems which don't allow autoloading because of old userspace.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Documentation/feature-removal-schedule.txt
drivers/hid/Kconfig
drivers/hid/Makefile
drivers/hid/hid-apple.c
drivers/hid/hid-core.c
drivers/hid/hid-dummy.c [new file with mode: 0644]
drivers/hid/hid-logitech.c
include/linux/hid.h

index cc8093c15cf5ce4c063aed880acfce7555903986..4d2566a7d16836d04f77c26bad5ebe6d38019dd9 100644 (file)
@@ -287,6 +287,13 @@ Who:       Glauber Costa <gcosta@redhat.com>
 
 ---------------------------
 
+What:  remove HID compat support
+When:  2.6.29
+Why:   needed only as a temporary solution until distros fix themselves up
+Who:   Jiri Slaby <jirislaby@gmail.com>
+
+---------------------------
+
 What:  /sys/o2cb symlink
 When:  January 2010
 Why:   /sys/fs/o2cb is the proper location for this information - /sys/o2cb
index 41283fff51455365e3fdd85ceccd5ae39a3279f2..d9d1a5671d957aab72011aed82055f3e695a9a67 100644 (file)
@@ -70,6 +70,18 @@ source "drivers/hid/usbhid/Kconfig"
 menu "Special HID drivers"
        depends on HID
 
+config HID_COMPAT
+       bool "Load all HID drivers on hid core load"
+       default y
+       ---help---
+       Compatible option for older userspace. If you have system without udev
+       support of module loading through aliases and also old
+       module-init-tools which can't handle hid bus, choose Y here. Otherwise
+       say N. If you say N and your userspace is old enough, the only
+       functionality you loose is modules autoloading.
+
+       If unsure, say Y.
+
 config HID_APPLE
        tristate "Apple"
        default m
index 4a14821ceefa57a7fbb37ed68c5d7888dfa73113..8e053eca474218b33e84fd2d356873e5794bce47 100644 (file)
@@ -8,6 +8,10 @@ obj-$(CONFIG_HID)              += hid.o
 hid-$(CONFIG_HID_DEBUG)                += hid-debug.o
 hid-$(CONFIG_HIDRAW)           += hidraw.o
 
+ifdef CONFIG_HID_COMPAT
+obj-m                          += hid-dummy.o
+endif
+
 obj-$(CONFIG_HID_APPLE)                += hid-apple.o
 obj-$(CONFIG_HID_LOGITECH)     += hid-logitech.o
 
index 5642e2c685fc6e572db149bd2d9dc4a6e1e61879..2a68661fcea8df2d93fe6b4f606f5b2bccb051e2 100644 (file)
@@ -477,3 +477,5 @@ static void apple_exit(void)
 module_init(apple_init);
 module_exit(apple_exit);
 MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(apple);
index 8e3c264c9b2b8500b181532f622e7fae0037b248..397e1b2ffe5a561d761644a08c75f86391ad1173 100644 (file)
@@ -1532,6 +1532,14 @@ void hid_unregister_driver(struct hid_driver *hdrv)
 }
 EXPORT_SYMBOL_GPL(hid_unregister_driver);
 
+#ifdef CONFIG_HID_COMPAT
+static void hid_compat_load(struct work_struct *ws)
+{
+       request_module("hid-dummy");
+}
+static DECLARE_WORK(hid_compat_work, hid_compat_load);
+#endif
+
 static int __init hid_init(void)
 {
        int ret;
@@ -1546,6 +1554,10 @@ static int __init hid_init(void)
        if (ret)
                goto err_bus;
 
+#ifdef CONFIG_HID_COMPAT
+       schedule_work(&hid_compat_work);
+#endif
+
        return 0;
 err_bus:
        bus_unregister(&hid_bus_type);
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
new file mode 100644 (file)
index 0000000..b76c44e
--- /dev/null
@@ -0,0 +1,18 @@
+#include <linux/autoconf.h>
+#include <linux/module.h>
+#include <linux/hid.h>
+
+static int __init hid_dummy_init(void)
+{
+#ifdef CONFIG_HID_APPLE_MODULE
+       HID_COMPAT_CALL_DRIVER(apple);
+#endif
+#ifdef CONFIG_HID_LOGITECH_MODULE
+       HID_COMPAT_CALL_DRIVER(logitech);
+#endif
+
+       return -EIO;
+}
+module_init(hid_dummy_init);
+
+MODULE_LICENSE("GPL");
index 395e42ffb4d58c59a20aabb86147d25b493b5f6a..b2aaebe1ac052ba0b6a22cbf30cec57c730a2a37 100644 (file)
@@ -310,3 +310,5 @@ static void lg_exit(void)
 module_init(lg_init);
 module_exit(lg_exit);
 MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(logitech);
index 75cc1531dd84f8f0673b3c5d20c5a8169325e310..60e44e6b86e6311866e024bd8c8ab31cbd789cba 100644 (file)
@@ -790,10 +790,23 @@ dbg_hid(const char *fmt, ...)
        return 0;
 }
 #define dbg_hid_line dbg_hid
-#endif
+#endif /* HID_DEBUG */
 
 #define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
                __FILE__ , ## arg)
-#endif
+#endif /* HID_FF */
+
+#ifdef CONFIG_HID_COMPAT
+#define HID_COMPAT_LOAD_DRIVER(name)   \
+void hid_compat_##name(void) { }       \
+EXPORT_SYMBOL(hid_compat_##name)
+#else
+#define HID_COMPAT_LOAD_DRIVER(name)
+#endif /* HID_COMPAT */
+#define HID_COMPAT_CALL_DRIVER(name)   do {    \
+       extern void hid_compat_##name(void);    \
+       hid_compat_##name();                    \
+} while (0)
+
 #endif