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>
This commit is contained in:
parent
5906215bab
commit
43e5e7c60e
4 changed files with 73 additions and 0 deletions
|
@ -29,6 +29,9 @@ hid-wiimote-y := hid-wiimote-core.o
|
||||||
ifdef CONFIG_HID_WIIMOTE_EXT
|
ifdef CONFIG_HID_WIIMOTE_EXT
|
||||||
hid-wiimote-y += hid-wiimote-ext.o
|
hid-wiimote-y += hid-wiimote-ext.o
|
||||||
endif
|
endif
|
||||||
|
ifdef CONFIG_DEBUG_FS
|
||||||
|
hid-wiimote-y += hid-wiimote-debug.o
|
||||||
|
endif
|
||||||
|
|
||||||
obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
|
obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
|
||||||
obj-$(CONFIG_HID_ACRUX) += hid-axff.o
|
obj-$(CONFIG_HID_ACRUX) += hid-axff.o
|
||||||
|
|
|
@ -1161,6 +1161,7 @@ err:
|
||||||
|
|
||||||
static void wiimote_destroy(struct wiimote_data *wdata)
|
static void wiimote_destroy(struct wiimote_data *wdata)
|
||||||
{
|
{
|
||||||
|
wiidebug_deinit(wdata);
|
||||||
wiiext_deinit(wdata);
|
wiiext_deinit(wdata);
|
||||||
wiimote_leds_destroy(wdata);
|
wiimote_leds_destroy(wdata);
|
||||||
|
|
||||||
|
@ -1237,6 +1238,10 @@ static int wiimote_hid_probe(struct hid_device *hdev,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_free;
|
goto err_free;
|
||||||
|
|
||||||
|
ret = wiidebug_init(wdata);
|
||||||
|
if (ret)
|
||||||
|
goto err_free;
|
||||||
|
|
||||||
hid_info(hdev, "New device registered\n");
|
hid_info(hdev, "New device registered\n");
|
||||||
|
|
||||||
/* by default set led1 after device initialization */
|
/* by default set led1 after device initialization */
|
||||||
|
|
52
drivers/hid/hid-wiimote-debug.c
Normal file
52
drivers/hid/hid-wiimote-debug.c
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -74,6 +74,7 @@ struct wiimote_data {
|
||||||
struct input_dev *ir;
|
struct input_dev *ir;
|
||||||
struct power_supply battery;
|
struct power_supply battery;
|
||||||
struct wiimote_ext *ext;
|
struct wiimote_ext *ext;
|
||||||
|
struct wiimote_debug *debug;
|
||||||
|
|
||||||
spinlock_t qlock;
|
spinlock_t qlock;
|
||||||
__u8 head;
|
__u8 head;
|
||||||
|
@ -137,6 +138,18 @@ static inline void wiiext_handle(void *u, const __u8 *p) { }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FS
|
||||||
|
|
||||||
|
extern int wiidebug_init(struct wiimote_data *wdata);
|
||||||
|
extern void wiidebug_deinit(struct wiimote_data *wdata);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static inline int wiidebug_init(void *u) { return 0; }
|
||||||
|
static inline void wiidebug_deinit(void *u) { }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* requires the state.lock spinlock to be held */
|
/* requires the state.lock spinlock to be held */
|
||||||
static inline bool wiimote_cmd_pending(struct wiimote_data *wdata, int cmd,
|
static inline bool wiimote_cmd_pending(struct wiimote_data *wdata, int cmd,
|
||||||
__u32 opt)
|
__u32 opt)
|
||||||
|
|
Loading…
Add table
Reference in a new issue