Hello, In the process of cleaning up the remaining schedule_timeout()s in the current kernel, I came across drivers/usb/class/usblp.c::usblp_write(). in this function, the second (counting by nesting) while-loop seemed very confusing to me. I believe the following patch would have the same result but is significantly cleaner. Would someone be able to test this and / or verify my belief?
Thanks, Nish Description: The while-loop seemed excessively blocked with conditionals. By reorganizing the code so timeout is the condition for the loop and changing the checks within the loop, several lines of code were removed. Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]> --- 2.6.9-bk7-vanilla/drivers/usb/class/usblp.c 2004-10-22 10:41:05.000000000 -0700 +++ 2.6.9-bk7/drivers/usb/class/usblp.c 2004-10-22 15:48:38.000000000 -0700 @@ -636,19 +636,16 @@ static ssize_t usblp_write(struct file * timeout = USBLP_WRITE_TIMEOUT; add_wait_queue(&usblp->wait, &wait); - while ( 1==1 ) { - + while (timeout) { if (signal_pending(current)) { remove_wait_queue(&usblp->wait, &wait); return writecount ? writecount : -EINTR; } - set_current_state(TASK_INTERRUPTIBLE); - if (timeout && !usblp->wcomplete) { - timeout = schedule_timeout(timeout); - } else { - set_current_state(TASK_RUNNING); + if (usblp->wcomplete) { break; } + set_current_state(TASK_INTERRUPTIBLE); + timeout = schedule_timeout(timeout); } remove_wait_queue(&usblp->wait, &wait); } ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel