From: Vojtech Pavlik <vojtech@suse.cz>
To: torvalds@osdl.org, dtor_core@ameritech.net,
linux-kernel@vger.kernel.org, vojtech@suse.cz
Subject: [PATCH 17/26] iforce - use wait_event_interruptible_timeout
Date: Sun, 11 Sep 2005 00:34:13 +0200 [thread overview]
Message-ID: <11263916532207@midnight.ucw.cz> (raw)
In-Reply-To: <11263916532348@midnight.ucw.cz>
Subject: [PATCH] Input: iforce - use wait_event_interruptible_timeout
From: Vojtech Pavlik <vojtech@suse.cz>
Date: 1125897159 -0500
The timeout while() loops in iforce-packets.c lack a
set_current_state(TASK_INTERRUPTIBLE); call. The right solution is
to replace them with wait_event_interruptible_timeout().
Reported-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/joystick/iforce/iforce-packets.c | 32 +++++-------------------
drivers/input/joystick/iforce/iforce-usb.c | 1 +
2 files changed, 8 insertions(+), 25 deletions(-)
fb76b099f86624d3c629cfab071aa2296f65b7bb
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce
int iforce_get_id_packet(struct iforce *iforce, char *packet)
{
- DECLARE_WAITQUEUE(wait, current);
- int timeout = HZ; /* 1 second */
-
switch (iforce->bus) {
case IFORCE_USB:
@@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *
iforce->cr.bRequest = packet[0];
iforce->ctrl->dev = iforce->usbdev;
- set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue(&iforce->wait, &wait);
-
- if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) {
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&iforce->wait, &wait);
+ if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC))
return -1;
- }
- while (timeout && iforce->ctrl->status == -EINPROGRESS)
- timeout = schedule_timeout(timeout);
+ wait_event_interruptible_timeout(iforce->wait,
+ iforce->ctrl->status != -EINPROGRESS, HZ);
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&iforce->wait, &wait);
-
- if (!timeout) {
+ if (iforce->ctrl->status != -EINPROGRESS) {
usb_unlink_urb(iforce->ctrl);
return -1;
}
@@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *
iforce->expect_packet = FF_CMD_QUERY;
iforce_send_packet(iforce, FF_CMD_QUERY, packet);
- set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue(&iforce->wait, &wait);
-
- while (timeout && iforce->expect_packet)
- timeout = schedule_timeout(timeout);
-
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&iforce->wait, &wait);
+ wait_event_interruptible_timeout(iforce->wait,
+ !iforce->expect_packet, HZ);
- if (!timeout) {
+ if (iforce->expect_packet) {
iforce->expect_packet = 0;
return -1;
}
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *u
goto exit;
}
+ wake_up(&iforce->wait);
iforce_process_packet(iforce,
(iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs);
next prev parent reply other threads:[~2005-09-10 22:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-10 22:32 [GIT PULL 0/26] Input update Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 1/26] psmouse - add support for IBM TrackPoint devices Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 2/26] rework psmouse attributes to reduce module size Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 3/26] ALPS - fix wheel decoding Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 4/26] psmouse - add new Logitech wheel mouse model Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 5/26] fix checking whether new keycode fits size-wise Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 6/26] i8042 - clean up initialization code; abort if we Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 7/26] make i8042_platform_init return 'real' error code Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 8/26] i8042 - fix IRQ printing when either KBD or AUX port Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 9/26] i8042 - add i8042.nokbd module option to allow supressing Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 10/26] i8042 - add Lifebook E4010 to MUX blacklist Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 11/26] recognize and ignore Logitech vendor usages in HID Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 12/26] add HID simulation mappings Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 13/26] HID - add more consumer usages Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 14/26] atkbd - handle keyboards generating scancode 0x7f Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 15/26] HID - handle multi-transascion reports Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 16/26] HID - add support for Logitech UltraX Media Remote control Vojtech Pavlik
2005-09-10 22:34 ` Vojtech Pavlik [this message]
2005-09-10 22:34 ` [PATCH 18/26] sunkbd - extend mapping to handle Type-6 Sun keyboards Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 19/26] HID - fix URB success status handling Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 20/26] HID - add a quirk for the Apple Powermouse Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 21/26] HID - add the Trust Predator TH 400 gamepad to the badpad list Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 22/26] HID - add mapping for Powerbook USB keyboard Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 23/26] HID - add Wireless Security Lock to HID blacklist Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 24/26] HIDDEV - make HIDIOCSREPORT wait IO completion Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 25/26] clean up whitespace and formatting in drivers/char/keyboard.c Vojtech Pavlik
2005-09-10 22:34 ` [PATCH 26/26] i8042 - use kzalloc instead of kcalloc Vojtech Pavlik
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=11263916532207@midnight.ucw.cz \
--to=vojtech@suse.cz \
--cc=dtor_core@ameritech.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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