aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/joystick/iforce/iforce-packets.c32
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c1
2 files changed, 8 insertions, 25 deletions
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index 58728ebaaf80..e5a31e55d3e2 100644
--- 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 *iforce, u16 cmd, unsigned char *data,
249 249
250int iforce_get_id_packet(struct iforce *iforce, char *packet) 250int iforce_get_id_packet(struct iforce *iforce, char *packet)
251{ 251{
252 DECLARE_WAITQUEUE(wait, current);
253 int timeout = HZ; /* 1 second */
254
255 switch (iforce->bus) { 252 switch (iforce->bus) {
256 253
257 case IFORCE_USB: 254 case IFORCE_USB:
@@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
260 iforce->cr.bRequest = packet[0]; 257 iforce->cr.bRequest = packet[0];
261 iforce->ctrl->dev = iforce->usbdev; 258 iforce->ctrl->dev = iforce->usbdev;
262 259
263 set_current_state(TASK_INTERRUPTIBLE); 260 if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC))
264 add_wait_queue(&iforce->wait, &wait);
265
266 if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) {
267 set_current_state(TASK_RUNNING);
268 remove_wait_queue(&iforce->wait, &wait);
269 return -1; 261 return -1;
270 }
271 262
272 while (timeout && iforce->ctrl->status == -EINPROGRESS) 263 wait_event_interruptible_timeout(iforce->wait,
273 timeout = schedule_timeout(timeout); 264 iforce->ctrl->status != -EINPROGRESS, HZ);
274 265
275 set_current_state(TASK_RUNNING); 266 if (iforce->ctrl->status != -EINPROGRESS) {
276 remove_wait_queue(&iforce->wait, &wait);
277
278 if (!timeout) {
279 usb_unlink_urb(iforce->ctrl); 267 usb_unlink_urb(iforce->ctrl);
280 return -1; 268 return -1;
281 } 269 }
@@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
290 iforce->expect_packet = FF_CMD_QUERY; 278 iforce->expect_packet = FF_CMD_QUERY;
291 iforce_send_packet(iforce, FF_CMD_QUERY, packet); 279 iforce_send_packet(iforce, FF_CMD_QUERY, packet);
292 280
293 set_current_state(TASK_INTERRUPTIBLE); 281 wait_event_interruptible_timeout(iforce->wait,
294 add_wait_queue(&iforce->wait, &wait); 282 !iforce->expect_packet, HZ);
295
296 while (timeout && iforce->expect_packet)
297 timeout = schedule_timeout(timeout);
298
299 set_current_state(TASK_RUNNING);
300 remove_wait_queue(&iforce->wait, &wait);
301 283
302 if (!timeout) { 284 if (iforce->expect_packet) {
303 iforce->expect_packet = 0; 285 iforce->expect_packet = 0;
304 return -1; 286 return -1;
305 } 287 }
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 6369a24684fe..58600f91eff5 100644
--- 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 *urb, struct pt_regs *regs)
95 goto exit; 95 goto exit;
96 } 96 }
97 97
98 wake_up(&iforce->wait);
98 iforce_process_packet(iforce, 99 iforce_process_packet(iforce,
99 (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); 100 (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs);
100 101