From 92eda7e4e5f9728e643553b378f55c75739554c2 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 May 2013 23:12:45 +0200 Subject: HID: wiimote: extend driver description The hid-wiimote driver supports more than the Wii Remote. Nintendo produced many devices based on the Wii Remote, which have extension devices built-in. It is not clear to many users, that these devices have anything in common with the Wii Remote, so fix the driver description. This also updates the copyright information for the coming hotplugging rework. Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/hid/hid-wiimote-debug.c') diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c index 90124ffaa2a5..fdd30dd71ef8 100644 --- a/drivers/hid/hid-wiimote-debug.c +++ b/drivers/hid/hid-wiimote-debug.c @@ -1,6 +1,6 @@ /* - * Debug support for HID Nintendo Wiimote devices - * Copyright (c) 2011 David Herrmann + * Debug support for HID Nintendo Wii / Wii U peripherals + * Copyright (c) 2011-2013 David Herrmann */ /* -- cgit v1.2.3 From 51103c70bf8d48395ff77eee387e6c94f0216630 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 May 2013 23:13:02 +0200 Subject: HID: wiimote: fix ctx pointer in debugfs DRM-write single_open() stores the seq_file pointer in file->private_data. It stores our ctx pointer in seq_file->private. Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote-debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/hid/hid-wiimote-debug.c') diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c index fdd30dd71ef8..0c0deaa23774 100644 --- a/drivers/hid/hid-wiimote-debug.c +++ b/drivers/hid/hid-wiimote-debug.c @@ -127,7 +127,8 @@ static int wiidebug_drm_open(struct inode *i, struct file *f) static ssize_t wiidebug_drm_write(struct file *f, const char __user *u, size_t s, loff_t *off) { - struct wiimote_debug *dbg = f->private_data; + struct seq_file *sf = f->private_data; + struct wiimote_debug *dbg = sf->private; unsigned long flags; char buf[16]; ssize_t len; -- cgit v1.2.3 From d76f89e13a0439649120a85297085e8d8fff77ec Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 May 2013 23:13:03 +0200 Subject: 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 Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote-debug.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/hid/hid-wiimote-debug.c') 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, i = simple_strtoul(buf, NULL, 10); spin_lock_irqsave(&dbg->wdata->state.lock, flags); + dbg->wdata->state.flags &= ~WIIPROTO_FLAG_DRM_LOCKED; wiiproto_req_drm(dbg->wdata, (__u8) i); + if (i != WIIPROTO_REQ_NULL) + dbg->wdata->state.flags |= WIIPROTO_FLAG_DRM_LOCKED; spin_unlock_irqrestore(&dbg->wdata->state.lock, flags); return len; -- cgit v1.2.3 From 0d57eb8758c865a70dd05f7c6a857acd996167fa Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 May 2013 23:13:09 +0200 Subject: HID: wiimote: fix DRM debug-attr to correctly parse input We need to correctly zero-terminate the input to parse it. Otherwise, we always end up interpreting it as numbers. Furthermore, we actually want hexadecimal numbers instead of decimal. As it is a debugfs interface, we can change the API at any time. Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/hid/hid-wiimote-debug.c') diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c index 6e76a2c3b00a..c13fb5bd79e8 100644 --- a/drivers/hid/hid-wiimote-debug.c +++ b/drivers/hid/hid-wiimote-debug.c @@ -141,7 +141,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u, if (copy_from_user(buf, u, len)) return -EFAULT; - buf[15] = 0; + buf[len] = 0; for (i = 0; i < WIIPROTO_REQ_MAX; ++i) { if (!wiidebug_drmmap[i]) @@ -151,7 +151,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u, } if (i == WIIPROTO_REQ_MAX) - i = simple_strtoul(buf, NULL, 10); + i = simple_strtoul(buf, NULL, 16); spin_lock_irqsave(&dbg->wdata->state.lock, flags); dbg->wdata->state.flags &= ~WIIPROTO_FLAG_DRM_LOCKED; -- cgit v1.2.3