Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by

Vojtech Pavlik and committed by
Dmitry Torokhov
fb76b099 39fd748f

+8 -25
+7 -25
drivers/input/joystick/iforce/iforce-packets.c
··· 249 249 250 250 int iforce_get_id_packet(struct iforce *iforce, char *packet) 251 251 { 252 - DECLARE_WAITQUEUE(wait, current); 253 - int timeout = HZ; /* 1 second */ 254 - 255 252 switch (iforce->bus) { 256 253 257 254 case IFORCE_USB: ··· 257 260 iforce->cr.bRequest = packet[0]; 258 261 iforce->ctrl->dev = iforce->usbdev; 259 262 260 - set_current_state(TASK_INTERRUPTIBLE); 261 - add_wait_queue(&iforce->wait, &wait); 262 - 263 - if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) { 264 - set_current_state(TASK_RUNNING); 265 - remove_wait_queue(&iforce->wait, &wait); 263 + if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) 266 264 return -1; 267 - } 268 265 269 - while (timeout && iforce->ctrl->status == -EINPROGRESS) 270 - timeout = schedule_timeout(timeout); 266 + wait_event_interruptible_timeout(iforce->wait, 267 + iforce->ctrl->status != -EINPROGRESS, HZ); 271 268 272 - set_current_state(TASK_RUNNING); 273 - remove_wait_queue(&iforce->wait, &wait); 274 - 275 - if (!timeout) { 269 + if (iforce->ctrl->status != -EINPROGRESS) { 276 270 usb_unlink_urb(iforce->ctrl); 277 271 return -1; 278 272 } ··· 278 290 iforce->expect_packet = FF_CMD_QUERY; 279 291 iforce_send_packet(iforce, FF_CMD_QUERY, packet); 280 292 281 - set_current_state(TASK_INTERRUPTIBLE); 282 - add_wait_queue(&iforce->wait, &wait); 293 + wait_event_interruptible_timeout(iforce->wait, 294 + !iforce->expect_packet, HZ); 283 295 284 - while (timeout && iforce->expect_packet) 285 - timeout = schedule_timeout(timeout); 286 - 287 - set_current_state(TASK_RUNNING); 288 - remove_wait_queue(&iforce->wait, &wait); 289 - 290 - if (!timeout) { 296 + if (iforce->expect_packet) { 291 297 iforce->expect_packet = 0; 292 298 return -1; 293 299 }
+1
drivers/input/joystick/iforce/iforce-usb.c
··· 95 95 goto exit; 96 96 } 97 97 98 + wake_up(&iforce->wait); 98 99 iforce_process_packet(iforce, 99 100 (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); 100 101