diff options
author | David Herrmann <dh.herrmann@googlemail.com> | 2011-11-17 08:12:10 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-11-22 17:10:26 -0500 |
commit | 43e5e7c60ee7039f538ccfaaa4e99829719d9bea (patch) | |
tree | c97a33352738f583e8f0c563af733914e02b147a /drivers/hid | |
parent | 5906215bab9fccf7aa2c4305accf0716c4634d69 (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/Makefile | 3 | ||||
-rw-r--r-- | drivers/hid/hid-wiimote-core.c | 5 | ||||
-rw-r--r-- | drivers/hid/hid-wiimote-debug.c | 52 | ||||
-rw-r--r-- | drivers/hid/hid-wiimote.h | 13 |
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 | |||
29 | ifdef CONFIG_HID_WIIMOTE_EXT | 29 | ifdef CONFIG_HID_WIIMOTE_EXT |
30 | hid-wiimote-y += hid-wiimote-ext.o | 30 | hid-wiimote-y += hid-wiimote-ext.o |
31 | endif | 31 | endif |
32 | ifdef CONFIG_DEBUG_FS | ||
33 | hid-wiimote-y += hid-wiimote-debug.o | ||
34 | endif | ||
32 | 35 | ||
33 | obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o | 36 | obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o |
34 | obj-$(CONFIG_HID_ACRUX) += hid-axff.o | 37 | obj-$(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 | ||
1162 | static void wiimote_destroy(struct wiimote_data *wdata) | 1162 | static 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 | |||
17 | struct wiimote_debug { | ||
18 | struct wiimote_data *wdata; | ||
19 | }; | ||
20 | |||
21 | int 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 | |||
39 | void 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 | |||
143 | extern int wiidebug_init(struct wiimote_data *wdata); | ||
144 | extern void wiidebug_deinit(struct wiimote_data *wdata); | ||
145 | |||
146 | #else | ||
147 | |||
148 | static inline int wiidebug_init(void *u) { return 0; } | ||
149 | static 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 */ |
141 | static inline bool wiimote_cmd_pending(struct wiimote_data *wdata, int cmd, | 154 | static inline bool wiimote_cmd_pending(struct wiimote_data *wdata, int cmd, |
142 | __u32 opt) | 155 | __u32 opt) |