[RFC 8/8] test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just demonstrative example.

---
 drivers/hid/Makefile   |    2 +-
 drivers/hid/hid-core.c |    1 +
 drivers/hid/test.c     |   62 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hid/test.c

diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 8a5cbbe..e607b7b 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -3,7 +3,7 @@
 #
 hid-objs			:= hid-core.o hid-input.o hid-input-quirks.o
 
-obj-$(CONFIG_HID)		+= hid.o
+obj-$(CONFIG_HID)		+= hid.o test.o
 
 hid-$(CONFIG_HID_DEBUG)		+= hid-debug.o
 hid-$(CONFIG_HIDRAW)		+= hidraw.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index e1b17e7..aff61c6 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1155,6 +1155,7 @@ static const struct hid_device_id hid_usb_blacklist[] = {
 	{ HID_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
 	{ HID_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
 	{ HID_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
+	{ HID_DEVICE(0x045e, 0x00f0) },
 	{ }
 };
 
diff --git a/drivers/hid/test.c b/drivers/hid/test.c
new file mode 100644
index 0000000..3633199
--- /dev/null
+++ b/drivers/hid/test.c
@@ -0,0 +1,62 @@
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+static const struct hid_report_id t_report_table[] = {
+	{ HID_REPORT_ID(0) },
+	{ HID_TERMINATOR }
+};
+
+static int t_raw_event(struct hid_device *hdev, struct hid_report *report,
+		u8 *data, int size)
+{
+/*	printk(KERN_DEBUG "report: %u, %u, %d, %.8x\n",
+			report->id, report->type,
+			size, __swab32(*((u32 *)data)));*/
+
+	return -ENODEV;
+}
+
+static const struct hid_usage_id t_usage_table[] = {
+	{ HID_USAGE_ID(HID_ANY_ID, 8) },
+	{ HID_TERMINATOR }
+};
+
+static int t_event(struct hid_device *hdev, struct hid_field *field,
+		struct hid_usage *usage, __s32 value)
+{
+/*	printk(KERN_DEBUG "usage: %u %u %u %d\n",
+			usage->hid, usage->code, usage->type, value);*/
+
+	return -ENODEV;
+}
+
+static const struct hid_device_id t_devices[] = {
+	{ HID_DEVICE(0x045e, 0x00f0) },
+	{ }
+};
+MODULE_DEVICE_TABLE(hid, t_devices);
+
+static struct hid_driver t_driver = {
+	.name = "test-usb",
+	.bus_type = BUS_USB,
+	.id_table = t_devices,
+	.usage_table = t_usage_table,
+	.event = t_event,
+	.report_table = t_report_table,
+	.raw_event = t_raw_event,
+};
+
+static int t_init(void)
+{
+	return hid_register_driver(&t_driver);
+}
+
+static void t_exit(void)
+{
+	hid_unregister_driver(&t_driver);
+}
+
+module_init(t_init);
+module_exit(t_exit);
+MODULE_LICENSE("GPL");
-- 
1.5.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux