diff options
author | David Herrmann <dh.herrmann@googlemail.com> | 2011-11-17 14:12:10 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-11-22 23:10:26 +0100 |
commit | 43e5e7c60ee7039f538ccfaaa4e99829719d9bea (patch) | |
tree | c97a33352738f583e8f0c563af733914e02b147a /drivers/hid/hid-wiimote-debug.c | |
parent | 5906215bab9fccf7aa2c4305accf0716c4634d69 (diff) | |
download | linux-3.10-43e5e7c60ee7039f538ccfaaa4e99829719d9bea.tar.gz linux-3.10-43e5e7c60ee7039f538ccfaaa4e99829719d9bea.tar.bz2 linux-3.10-43e5e7c60ee7039f538ccfaaa4e99829719d9bea.zip |
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/hid-wiimote-debug.c')
-rw-r--r-- | drivers/hid/hid-wiimote-debug.c | 52 |
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 00000000000..6282e3c1a36 --- /dev/null +++ b/drivers/hid/hid-wiimote-debug.c @@ -0,0 +1,52 @@ +/* + * Debug support for HID Nintendo Wiimote devices + * Copyright (c) 2011 David Herrmann + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <linux/module.h> +#include <linux/spinlock.h> +#include "hid-wiimote.h" + +struct wiimote_debug { + struct wiimote_data *wdata; +}; + +int wiidebug_init(struct wiimote_data *wdata) +{ + struct wiimote_debug *dbg; + unsigned long flags; + + dbg = kzalloc(sizeof(*dbg), GFP_KERNEL); + if (!dbg) + return -ENOMEM; + + dbg->wdata = wdata; + + spin_lock_irqsave(&wdata->state.lock, flags); + wdata->debug = dbg; + spin_unlock_irqrestore(&wdata->state.lock, flags); + + return 0; +} + +void wiidebug_deinit(struct wiimote_data *wdata) +{ + struct wiimote_debug *dbg = wdata->debug; + unsigned long flags; + + if (!dbg) + return; + + spin_lock_irqsave(&wdata->state.lock, flags); + wdata->debug = NULL; + spin_unlock_irqrestore(&wdata->state.lock, flags); + + kfree(dbg); +} |