Alan Stern wrote:
+static int sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, + void *data, int len, int *actual_length, int timeout, + unsigned int tflags, dma_addr_t transfer_dma)
+{
<...>
+ /* If OK, and if timeout > 0, wait for completion */
+ if((retval == 0) && timeout) {
+ if(sisusb->urbstatus[index] & SU_URB_BUSY) {
+ add_wait_queue(&sisusb->wait_q, &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
+ while(1) {
+ if(timeout && (sisusb->urbstatus[index] & SU_URB_BUSY)) {
+ timeout = schedule_timeout(timeout);
+ } else {
+ set_current_state(TASK_RUNNING);
+ break;
+ }
+ }
+ remove_wait_queue(&sisusb->wait_q, &wait);
+ }
+ retval = urb->status;
+ if(retval == -ECONNRESET) retval = -ETIMEDOUT;


While this is technically okay, it's bad form since you're not supposed
to look at urb->status until the completion handler has run.  Also, if
the URB does time out you don't unlink it anywhere.  So how can urb->status
ever get set to -ECONNRESET?

OK, this one better?

if((retval == 0) && timeout) {
        if(sisusb->urbstatus[index] & SU_URB_BUSY) {     
           add_wait_queue(&sisusb->wait_q, &wait);
           set_current_state(TASK_INTERRUPTIBLE);
           while(1) {
             if(timeout && (sisusb->urbstatus[index] & SU_URB_BUSY)) {
                timeout = schedule_timeout(timeout);
             } else {
                set_current_state(TASK_RUNNING);
                break;
             }
           }
           remove_wait_queue(&sisusb->wait_q, &wait);
        }
        if(sisusb->urbstatus[index] & SU_URB_BUSY) {
                /* URB timed out... kill it and report error */
                usb_kill_urb(urb);
                retval = -ETIMEDOUT;
        } else {
                /* Otherwise, report urb status */
                retval = urb->status;
                byteswritten = urb->actual_length;
        }
}

Thomas


-- Thomas Winischhofer Vienna/Austria thomas AT winischhofer DOT net *** http://www.winischhofer.net/ twini AT xfree86 DOT org



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to