aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-05-05 17:13:03 -0400
committerJiri Kosina <jkosina@suse.cz>2013-06-03 05:07:04 -0400
commitd76f89e13a0439649120a85297085e8d8fff77ec (patch)
tree2b4d434b7085dfba62a2dfb19cb50dc3d5f092e7
parent51103c70bf8d48395ff77eee387e6c94f0216630 (diff)
HID: wiimote: lock DRM mode during debugfs overwrite
If we write a DRM mode via debugfs, we shouldn't allow normal operations to overwrite this DRM mode. This is important if we want to debug 3rd-party devices and we want to see what data is sent on each mode. If we write NULL/0 as DRM, the lock is removed again so the best matching DRM is chosen by wiimote core. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-wiimote-core.c4
-rw-r--r--drivers/hid/hid-wiimote-debug.c3
-rw-r--r--drivers/hid/hid-wiimote.h1
3 files changed, 7 insertions, 1 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index f6c4773fac56..13963b4c8801 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -242,7 +242,9 @@ void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
242{ 242{
243 __u8 cmd[3]; 243 __u8 cmd[3];
244 244
245 if (drm == WIIPROTO_REQ_NULL) 245 if (wdata->state.flags & WIIPROTO_FLAG_DRM_LOCKED)
246 drm = wdata->state.drm;
247 else if (drm == WIIPROTO_REQ_NULL)
246 drm = select_drm(wdata); 248 drm = select_drm(wdata);
247 249
248 cmd[0] = WIIPROTO_REQ_DRM; 250 cmd[0] = WIIPROTO_REQ_DRM;
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index 0c0deaa23774..6e76a2c3b00a 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -154,7 +154,10 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
154 i = simple_strtoul(buf, NULL, 10); 154 i = simple_strtoul(buf, NULL, 10);
155 155
156 spin_lock_irqsave(&dbg->wdata->state.lock, flags); 156 spin_lock_irqsave(&dbg->wdata->state.lock, flags);
157 dbg->wdata->state.flags &= ~WIIPROTO_FLAG_DRM_LOCKED;
157 wiiproto_req_drm(dbg->wdata, (__u8) i); 158 wiiproto_req_drm(dbg->wdata, (__u8) i);
159 if (i != WIIPROTO_REQ_NULL)
160 dbg->wdata->state.flags |= WIIPROTO_FLAG_DRM_LOCKED;
158 spin_unlock_irqrestore(&dbg->wdata->state.lock, flags); 161 spin_unlock_irqrestore(&dbg->wdata->state.lock, flags);
159 162
160 return len; 163 return len;
diff --git a/drivers/hid/hid-wiimote.h b/drivers/hid/hid-wiimote.h
index 3a8bdb94152a..9f857c1cd84a 100644
--- a/drivers/hid/hid-wiimote.h
+++ b/drivers/hid/hid-wiimote.h
@@ -43,6 +43,7 @@
43#define WIIPROTO_FLAG_MP_USED 0x1000 43#define WIIPROTO_FLAG_MP_USED 0x1000
44#define WIIPROTO_FLAG_MP_ACTIVE 0x2000 44#define WIIPROTO_FLAG_MP_ACTIVE 0x2000
45#define WIIPROTO_FLAG_EXITING 0x4000 45#define WIIPROTO_FLAG_EXITING 0x4000
46#define WIIPROTO_FLAG_DRM_LOCKED 0x8000
46 47
47#define WIIPROTO_FLAGS_LEDS (WIIPROTO_FLAG_LED1 | WIIPROTO_FLAG_LED2 | \ 48#define WIIPROTO_FLAGS_LEDS (WIIPROTO_FLAG_LED1 | WIIPROTO_FLAG_LED2 | \
48 WIIPROTO_FLAG_LED3 | WIIPROTO_FLAG_LED4) 49 WIIPROTO_FLAG_LED3 | WIIPROTO_FLAG_LED4)