Commit fb76b099 authored by Vojtech Pavlik's avatar Vojtech Pavlik Committed by Dmitry Torokhov

Input: iforce - use wait_event_interruptible_timeout

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: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarVojtech Pavlik <vojtech@suse.cz>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 39fd748f
...@@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, ...@@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data,
int iforce_get_id_packet(struct iforce *iforce, char *packet) int iforce_get_id_packet(struct iforce *iforce, char *packet)
{ {
DECLARE_WAITQUEUE(wait, current);
int timeout = HZ; /* 1 second */
switch (iforce->bus) { switch (iforce->bus) {
case IFORCE_USB: case IFORCE_USB:
...@@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) ...@@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
iforce->cr.bRequest = packet[0]; iforce->cr.bRequest = packet[0];
iforce->ctrl->dev = iforce->usbdev; iforce->ctrl->dev = iforce->usbdev;
set_current_state(TASK_INTERRUPTIBLE); if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC))
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);
return -1; return -1;
}
while (timeout && iforce->ctrl->status == -EINPROGRESS) wait_event_interruptible_timeout(iforce->wait,
timeout = schedule_timeout(timeout); iforce->ctrl->status != -EINPROGRESS, HZ);
set_current_state(TASK_RUNNING); if (iforce->ctrl->status != -EINPROGRESS) {
remove_wait_queue(&iforce->wait, &wait);
if (!timeout) {
usb_unlink_urb(iforce->ctrl); usb_unlink_urb(iforce->ctrl);
return -1; return -1;
} }
...@@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) ...@@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
iforce->expect_packet = FF_CMD_QUERY; iforce->expect_packet = FF_CMD_QUERY;
iforce_send_packet(iforce, FF_CMD_QUERY, packet); iforce_send_packet(iforce, FF_CMD_QUERY, packet);
set_current_state(TASK_INTERRUPTIBLE); wait_event_interruptible_timeout(iforce->wait,
add_wait_queue(&iforce->wait, &wait); !iforce->expect_packet, HZ);
while (timeout && iforce->expect_packet)
timeout = schedule_timeout(timeout);
set_current_state(TASK_RUNNING);
remove_wait_queue(&iforce->wait, &wait);
if (!timeout) { if (iforce->expect_packet) {
iforce->expect_packet = 0; iforce->expect_packet = 0;
return -1; return -1;
} }
......
...@@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs) ...@@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs)
goto exit; goto exit;
} }
wake_up(&iforce->wait);
iforce_process_packet(iforce, iforce_process_packet(iforce,
(iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment