aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2011-11-17 08:12:10 -0500
committerJiri Kosina <jkosina@suse.cz>2011-11-22 17:10:26 -0500
commit43e5e7c60ee7039f538ccfaaa4e99829719d9bea (patch)
treec97a33352738f583e8f0c563af733914e02b147a /drivers/hid
parent5906215bab9fccf7aa2c4305accf0716c4634d69 (diff)
HID: wiimote: Add debugfs support stubs
Add initializer and deinitializer for debugfs support. This will later allow raw eeprom access and direct DRM modifications to debug wiimote behaviour and further protocol reverse-engineerings. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/Makefile3
-rw-r--r--drivers/hid/hid-wiimote-core.c5
-rw-r--r--drivers/hid/hid-wiimote-debug.c52
-rw-r--r--drivers/hid/hid-wiimote.h13
4 files changed, 73 insertions, 0 deletions
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 5fab4e632eab..15c1a84537eb 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -29,6 +29,9 @@ hid-wiimote-y := hid-wiimote-core.o
29ifdef CONFIG_HID_WIIMOTE_EXT 29ifdef CONFIG_HID_WIIMOTE_EXT
30 hid-wiimote-y += hid-wiimote-ext.o 30 hid-wiimote-y += hid-wiimote-ext.o
31endif 31endif
32ifdef CONFIG_DEBUG_FS
33 hid-wiimote-y += hid-wiimote-debug.o
34endif
32 35
33obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o 36obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
34obj-$(CONFIG_HID_ACRUX) += hid-axff.o 37obj-$(CONFIG_HID_ACRUX) += hid-axff.o
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index d8ed1ec58e9f..919abbaba840 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1161,6 +1161,7 @@ err:
1161 1161
1162static void wiimote_destroy(struct wiimote_data *wdata) 1162static void wiimote_destroy(struct wiimote_data *wdata)
1163{ 1163{
1164 wiidebug_deinit(wdata);
1164 wiiext_deinit(wdata); 1165 wiiext_deinit(wdata);
1165 wiimote_leds_destroy(wdata); 1166 wiimote_leds_destroy(wdata);
1166 1167
@@ -1237,6 +1238,10 @@ static int wiimote_hid_probe(struct hid_device *hdev,
1237 if (ret) 1238 if (ret)
1238 goto err_free; 1239 goto err_free;
1239 1240
1241 ret = wiidebug_init(wdata);
1242 if (ret)
1243 goto err_free;
1244
1240 hid_info(hdev, "New device registered\n"); 1245 hid_info(hdev, "New device registered\n");
1241 1246
1242 /* by default set led1 after device initialization */ 1247 /* by default set led1 after device initialization */
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
new file mode 100644
index 000000000000..6282e3c1a362
--- /dev/null
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -0,0 +1,52 @@
1/*
2 * Debug support for HID Nintendo Wiimote devices
3 * Copyright (c) 2011 David Herrmann
4 */
5
6/*
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 */
12
13#include <linux/module.h>
14#include <linux/spinlock.h>
15#include "hid-wiimote.h"
16
17struct wiimote_debug {
18 struct wiimote_data *wdata;
19};
20
21int wiidebug_init(struct wiimote_data *wdata)
22{
23 struct wiimote_debug *dbg;
24 unsigned long flags;
25
26 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
27 if (!dbg)
28 return -ENOMEM;
29
30 dbg->wdata = wdata;
31
32 spin_lock_irqsave(&wdata->state.lock, flags);
33 wdata->debug = dbg;
34 spin_unlock_irqrestore(&wdata->state.lock, flags);
35
36 return 0;
37}
38
39void wiidebug_deinit(struct wiimote_data *wdata)
40{
41 struct wiimote_debug *dbg = wdata->debug;
42 unsigned long flags;
43
44 if (!dbg)
45 return;
46
47 spin_lock_irqsave(&wdata->state.lock, flags);
48 wdata->debug = NULL;
49 spin_unlock_irqrestore(&wdata->state.lock, flags);
50
51 kfree(dbg);
52}
diff --git a/drivers/hid/hid-wiimote.h b/drivers/hid/hid-wiimote.h
index 1f3e53a3a148..89b8851dbf1f 100644
--- a/drivers/hid/hid-wiimote.h
+++ b/drivers/hid/hid-wiimote.h
@@ -74,6 +74,7 @@ struct wiimote_data {
74 struct input_dev *ir; 74 struct input_dev *ir;
75 struct power_supply battery; 75 struct power_supply battery;
76 struct wiimote_ext *ext; 76 struct wiimote_ext *ext;
77 struct wiimote_debug *debug;
77 78
78 spinlock_t qlock; 79 spinlock_t qlock;
79 __u8 head; 80 __u8 head;
@@ -137,6 +138,18 @@ static inline void wiiext_handle(void *u, const __u8 *p) { }
137 138
138#endif 139#endif
139 140
141#ifdef CONFIG_DEBUG_FS
142
143extern int wiidebug_init(struct wiimote_data *wdata);
144extern void wiidebug_deinit(struct wiimote_data *wdata);
145
146#else
147
148static inline int wiidebug_init(void *u) { return 0; }
149static inline void wiidebug_deinit(void *u) { }
150
151#endif
152
140/* requires the state.lock spinlock to be held */ 153/* requires the state.lock spinlock to be held */
141static inline bool wiimote_cmd_pending(struct wiimote_data *wdata, int cmd, 154static inline bool wiimote_cmd_pending(struct wiimote_data *wdata, int cmd,
142 __u32 opt) 155 __u32 opt)