From: Jiri Slaby <jirislaby@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org, marcel@holtmann.org,
linux-kernel@vger.kernel.org, anssi.hannula@gmail.com,
akpm@linux-foundation.org, Jiri Slaby <jirislaby@gmail.com>,
Sam Ravnborg <sam@ravnborg.org>
Subject: [PATCH 9/9] HID: add compat support
Date: Sun, 11 May 2008 22:00:43 +0200 [thread overview]
Message-ID: <1210536043-19812-9-git-send-email-jirislaby@gmail.com> (raw)
In-Reply-To: <1210536043-19812-8-git-send-email-jirislaby@gmail.com>
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>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
drivers/hid/Kconfig | 11 +++++++++++
drivers/hid/Makefile | 22 ++++++++++++++++++++++
drivers/hid/hid-apple.c | 2 ++
drivers/hid/hid-core.c | 12 ++++++++++++
drivers/hid/hid-dummy.c | 11 +++++++++++
drivers/hid/hid-logitech.c | 2 ++
include/linux/hid.h | 13 +++++++++++--
7 files changed, 71 insertions(+), 2 deletions(-)
create mode 100644 drivers/hid/hid-dummy.c
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 9a9fd7d..ba9ca39 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -70,6 +70,17 @@ source "drivers/hid/usbhid/Kconfig"
menu "Special HID drivers"
depends on HID
+config HID_COMPAT
+ bool "Load all HID drivers on hid core load"
+ ---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 N.
+
config HID_LOGITECH
tristate "Logitech"
default m
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 8a5cbbe..c5bca8f 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -15,3 +15,25 @@ obj-$(CONFIG_USB_HID) += usbhid/
obj-$(CONFIG_USB_MOUSE) += usbhid/
obj-$(CONFIG_USB_KBD) += usbhid/
+targets := hid-dummy.h
+
+ifdef CONFIG_HID_COMPAT
+
+obj-m += hid-dummy.o
+
+$(srctree)/$(src)/hid-dummy.c: $(obj)/hid-dummy.h
+
+$(obj)/hid-dummy.h: $(filter-out $(srctree)/drivers/hid/hid-dummy.c,$(wildcard $(srctree)/drivers/hid/*.c))
+ @echo -e 'static void __always_inline hid_dummy_load(void)\n{' > $@
+ @FUNS=`grep -h 'HID_COMPAT_LOAD_DRIVER(' $(srctree)/drivers/hid/*.c | \
+ sed -e 's/HID_COMPAT_LOAD_DRIVER( *\([^ ]*\) *) *;/\1/'`; \
+ for FUN in $$FUNS; do \
+ echo -e "\textern void hid_compat_$$FUN(void);"; \
+ done >> $@; \
+ echo >> $@; \
+ for FUN in $$FUNS; do \
+ echo -e "\thid_compat_$$FUN();"; \
+ done >> $@
+ @echo "}" >> $@
+
+endif
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index ce1c21f..b9f4b35 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -469,3 +469,5 @@ static void apple_exit(void)
module_init(apple_init);
module_exit(apple_exit);
MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(hid_apple);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 07676f2..e6532ec 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1570,6 +1570,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;
@@ -1584,6 +1592,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
index 0000000..8887188
--- /dev/null
+++ b/drivers/hid/hid-dummy.c
@@ -0,0 +1,11 @@
+#include <linux/module.h>
+#include "hid-dummy.h"
+
+static int __init hid_dummy_init(void)
+{
+ hid_dummy_load();
+ return -EIO;
+}
+module_init(hid_dummy_init);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-logitech.c b/drivers/hid/hid-logitech.c
index 5b145c9..6a70ca9 100644
--- a/drivers/hid/hid-logitech.c
+++ b/drivers/hid/hid-logitech.c
@@ -72,3 +72,5 @@ static void lg_exit(void)
module_init(lg_init);
module_exit(lg_exit);
MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(hid_logitech);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index b3669da..4dca3cc 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -784,10 +784,19 @@ 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 */
+
#endif
--
1.5.4.5
next prev parent reply other threads:[~2008-05-11 20:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-11 20:00 [PATCH 1/9] modpost: add support for hid Jiri Slaby
2008-05-11 20:00 ` [PATCH 2/9] HID: make a bus from hid code Jiri Slaby
2008-05-11 20:00 ` [PATCH 3/9] HID: hid, make parsing event driven Jiri Slaby
2008-05-11 20:00 ` [PATCH 4/9] HID: move ids into separate file Jiri Slaby
2008-05-11 20:00 ` [PATCH 5/9] HID: move usage input mapping to hid.h Jiri Slaby
2008-05-11 20:00 ` [PATCH 6/9] HID: move logitech report quirks Jiri Slaby
2008-05-11 20:00 ` [PATCH 7/9] HID: move ignore quirks Jiri Slaby
2008-05-11 20:00 ` [PATCH 8/9] HID: move apple quirks Jiri Slaby
2008-05-11 20:00 ` Jiri Slaby [this message]
2008-05-11 20:48 ` [PATCH 9/9] HID: add compat support Sam Ravnborg
2008-05-11 21:07 ` Jiri Slaby
2008-05-11 21:18 ` Sam Ravnborg
2008-05-12 7:19 ` Jiri Slaby
2008-05-11 23:18 ` Marcel Holtmann
2008-05-11 23:15 ` [PATCH 8/9] HID: move apple quirks Marcel Holtmann
2008-05-11 23:20 ` [PATCH 3/9] HID: hid, make parsing event driven Marcel Holtmann
2008-05-14 9:34 ` Jiri Slaby
2008-05-14 12:08 ` Jiri Kosina
2008-05-11 23:05 ` [PATCH 2/9] HID: make a bus from hid code Marcel Holtmann
2008-05-14 9:30 ` Jiri Slaby
2008-05-15 9:11 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1210536043-19812-9-git-send-email-jirislaby@gmail.com \
--to=jirislaby@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anssi.hannula@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).