aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-wiimote-debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-wiimote-debug.c')
-rw-r--r--drivers/hid/hid-wiimote-debug.c52
1 files changed, 52 insertions, 0 deletions
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}