From: David Herrmann <dh.herrmann@gmail.com>
To: linux-input@vger.kernel.org
Cc: Jiri Kosina <jkosina@suse.cz>, David Herrmann <dh.herrmann@gmail.com>
Subject: [PATCH 03/26] HID: wiimote: keep HID device open
Date: Sun, 5 May 2013 23:12:47 +0200 [thread overview]
Message-ID: <1367788390-29835-4-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1367788390-29835-1-git-send-email-dh.herrmann@gmail.com>
We need constant I/O to keep the state up-to-date and not miss any
packets. Hence, call hid_hw_open() during setup and hid_hw_close() during
destruction.
These are no-ops for Bluetooth HIDP, but lets be safe.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
drivers/hid/hid-wiimote-core.c | 48 ++++++++++--------------------------------
drivers/hid/hid-wiimote-ext.c | 12 -----------
2 files changed, 11 insertions(+), 49 deletions(-)
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 2d85d3a..02656a8 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -626,30 +626,11 @@ static int wiimote_ff_play(struct input_dev *dev, void *data,
return 0;
}
-static int wiimote_input_open(struct input_dev *dev)
-{
- struct wiimote_data *wdata = input_get_drvdata(dev);
-
- return hid_hw_open(wdata->hdev);
-}
-
-static void wiimote_input_close(struct input_dev *dev)
-{
- struct wiimote_data *wdata = input_get_drvdata(dev);
-
- hid_hw_close(wdata->hdev);
-}
-
static int wiimote_accel_open(struct input_dev *dev)
{
struct wiimote_data *wdata = input_get_drvdata(dev);
- int ret;
unsigned long flags;
- ret = hid_hw_open(wdata->hdev);
- if (ret)
- return ret;
-
spin_lock_irqsave(&wdata->state.lock, flags);
wiiproto_req_accel(wdata, true);
spin_unlock_irqrestore(&wdata->state.lock, flags);
@@ -665,26 +646,13 @@ static void wiimote_accel_close(struct input_dev *dev)
spin_lock_irqsave(&wdata->state.lock, flags);
wiiproto_req_accel(wdata, false);
spin_unlock_irqrestore(&wdata->state.lock, flags);
-
- hid_hw_close(wdata->hdev);
}
static int wiimote_ir_open(struct input_dev *dev)
{
struct wiimote_data *wdata = input_get_drvdata(dev);
- int ret;
-
- ret = hid_hw_open(wdata->hdev);
- if (ret)
- return ret;
-
- ret = wiimote_init_ir(wdata, WIIPROTO_FLAG_IR_BASIC);
- if (ret) {
- hid_hw_close(wdata->hdev);
- return ret;
- }
- return 0;
+ return wiimote_init_ir(wdata, WIIPROTO_FLAG_IR_BASIC);
}
static void wiimote_ir_close(struct input_dev *dev)
@@ -692,7 +660,6 @@ static void wiimote_ir_close(struct input_dev *dev)
struct wiimote_data *wdata = input_get_drvdata(dev);
wiimote_init_ir(wdata, 0);
- hid_hw_close(wdata->hdev);
}
static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
@@ -1091,8 +1058,6 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
hid_set_drvdata(hdev, wdata);
input_set_drvdata(wdata->input, wdata);
- wdata->input->open = wiimote_input_open;
- wdata->input->close = wiimote_input_close;
wdata->input->dev.parent = &wdata->hdev->dev;
wdata->input->id.bustype = wdata->hdev->bus;
wdata->input->id.vendor = wdata->hdev->vendor;
@@ -1193,6 +1158,7 @@ static void wiimote_destroy(struct wiimote_data *wdata)
input_unregister_device(wdata->ir);
input_unregister_device(wdata->input);
cancel_work_sync(&wdata->queue.worker);
+ hid_hw_close(wdata->hdev);
hid_hw_stop(wdata->hdev);
kfree(wdata);
@@ -1224,10 +1190,16 @@ static int wiimote_hid_probe(struct hid_device *hdev,
goto err;
}
+ ret = hid_hw_open(hdev);
+ if (ret) {
+ hid_err(hdev, "cannot start hardware I/O\n");
+ goto err_stop;
+ }
+
ret = input_register_device(wdata->accel);
if (ret) {
hid_err(hdev, "Cannot register input device\n");
- goto err_stop;
+ goto err_close;
}
ret = input_register_device(wdata->ir);
@@ -1298,6 +1270,8 @@ err_input:
err_ir:
input_unregister_device(wdata->accel);
wdata->accel = NULL;
+err_close:
+ hid_hw_close(hdev);
err_stop:
hid_hw_stop(hdev);
err:
diff --git a/drivers/hid/hid-wiimote-ext.c b/drivers/hid/hid-wiimote-ext.c
index 1c104fc..267c89c 100644
--- a/drivers/hid/hid-wiimote-ext.c
+++ b/drivers/hid/hid-wiimote-ext.c
@@ -661,11 +661,6 @@ static DEVICE_ATTR(extension, S_IRUGO, wiiext_show, NULL);
static int wiiext_input_open(struct input_dev *dev)
{
struct wiimote_ext *ext = input_get_drvdata(dev);
- int ret;
-
- ret = hid_hw_open(ext->wdata->hdev);
- if (ret)
- return ret;
atomic_inc(&ext->opened);
wiiext_schedule(ext);
@@ -679,17 +674,11 @@ static void wiiext_input_close(struct input_dev *dev)
atomic_dec(&ext->opened);
wiiext_schedule(ext);
- hid_hw_close(ext->wdata->hdev);
}
static int wiiext_mp_open(struct input_dev *dev)
{
struct wiimote_ext *ext = input_get_drvdata(dev);
- int ret;
-
- ret = hid_hw_open(ext->wdata->hdev);
- if (ret)
- return ret;
atomic_inc(&ext->mp_opened);
wiiext_schedule(ext);
@@ -703,7 +692,6 @@ static void wiiext_mp_close(struct input_dev *dev)
atomic_dec(&ext->mp_opened);
wiiext_schedule(ext);
- hid_hw_close(ext->wdata->hdev);
}
/* Initializes the extension driver of a wiimote */
--
1.8.2.2
next prev parent reply other threads:[~2013-05-05 21:13 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-05 21:12 [PATCH 00/26] Wii Remote Extension Hotplugging Support David Herrmann
2013-05-05 21:12 ` [PATCH 01/26] HID: wiimote: extend driver description David Herrmann
2013-06-03 9:19 ` Jiri Kosina
2013-06-03 20:28 ` David Herrmann
2013-05-05 21:12 ` [PATCH 02/26] HID: wiimote: move queue handling into separate struct David Herrmann
2013-05-05 21:12 ` David Herrmann [this message]
2013-05-05 21:12 ` [PATCH 04/26] HID: wiimote: add device detection David Herrmann
2013-05-05 21:12 ` [PATCH 05/26] HID: wiimote: use cached battery values on I/O failure David Herrmann
2013-05-05 21:12 ` [PATCH 06/26] HID: wiimote: wake up if output queue failed David Herrmann
2013-05-05 21:12 ` [PATCH 07/26] HID: wiimote: add sub-device module infrastructure David Herrmann
2013-05-05 21:12 ` [PATCH 08/26] HID: wiimote: convert KEYS and RUMBLE to modules David Herrmann
2013-05-05 21:12 ` [PATCH 09/26] HID: wiimote: convert BATTERY to module David Herrmann
2013-05-05 21:12 ` [PATCH 10/26] HID: wiimote: convert LEDS to modules David Herrmann
2013-05-05 21:12 ` [PATCH 11/26] HID: wiimote: convert ACCEL to module David Herrmann
2013-05-05 21:12 ` [PATCH 12/26] HID: wiimote: convert IR " David Herrmann
2013-05-05 21:12 ` [PATCH 13/26] HID: wiimote: add extension hotplug support David Herrmann
2013-05-23 10:53 ` David Herrmann
2013-05-23 12:28 ` Jiri Kosina
2013-05-05 21:12 ` [PATCH 14/26] HID: wiimote: add Balance Board support David Herrmann
2013-05-05 21:12 ` [PATCH 15/26] HID: wiimote: add Nunchuk support David Herrmann
2013-05-05 21:13 ` [PATCH 16/26] HID: wiimote: add Classic Controller extension David Herrmann
2013-05-06 0:39 ` Todd Showalter
2013-05-06 5:40 ` David Herrmann
2013-05-06 14:15 ` Todd Showalter
2013-05-05 21:13 ` [PATCH 17/26] HID: wiimote: add Motion Plus extension module David Herrmann
2013-05-05 21:13 ` [PATCH 18/26] HID: wiimote: fix ctx pointer in debugfs DRM-write David Herrmann
2013-05-05 21:13 ` [PATCH 19/26] HID: wiimote: lock DRM mode during debugfs overwrite David Herrmann
2013-05-05 21:13 ` [PATCH 20/26] HID: wiimote: add sysfs extension/device-type attrs David Herrmann
2013-05-05 21:13 ` [PATCH 21/26] HID: wiimote: add "bboard_calib" attribute David Herrmann
2013-05-05 21:13 ` [PATCH 22/26] HID: wiimote: remove old static extension support David Herrmann
2013-05-05 21:13 ` [PATCH 23/26] HID: wiimote: add MP quirks David Herrmann
2013-05-05 21:13 ` [RFC 24/26] HID: wiimote: support Nintendo Wii U Pro Controller David Herrmann
2013-05-06 0:43 ` Todd Showalter
2013-05-06 5:49 ` David Herrmann
2013-05-06 14:14 ` Todd Showalter
2013-05-08 15:33 ` David Herrmann
2013-05-08 16:40 ` Todd Showalter
2013-05-08 17:05 ` Dmitry Torokhov
2013-05-08 17:20 ` Todd Showalter
2013-05-08 17:25 ` David Herrmann
2013-05-08 17:26 ` Dmitry Torokhov
2013-05-13 17:03 ` David Herrmann
2013-05-13 17:40 ` Todd Showalter
2013-05-22 12:10 ` David Herrmann
2013-05-22 16:18 ` Todd Showalter
2013-05-05 21:13 ` [PATCH 25/26] HID: wiimote: fix DRM debug-attr to correctly parse input David Herrmann
2013-05-05 21:13 ` [RFC 26/26] HID/ALSA: wiimote: add speaker support David Herrmann
2013-05-26 20:55 ` [PATCH 27/26] HID: wiimote: init EXT/MP during device detection David Herrmann
2013-05-26 20:55 ` [PATCH 28/26] HID: wiimote: discard invalid EXT data reports David Herrmann
2013-05-26 20:55 ` [PATCH 29/26] HID: wiimote: fix classic controller parsing David Herrmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367788390-29835-4-git-send-email-dh.herrmann@gmail.com \
--to=dh.herrmann@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).