/*FUNCTION*---------------------------------------------------------------- * * Function Name : usb_dev_list_close_pipe * Returned Value : * Comments : * Cancel pending TR's and close a pipe. * *END*--------------------------------------------------------------------*/ static void usb_dev_list_close_pipe ( _usb_host_handle handle, PIPE_DESCRIPTOR_STRUCT_PTR pipe_ptr ) { /* Body */ USB_STATUS status; USB_HOST_STATE_STRUCT_PTR usb_host_ptr; PIPE_TR_STRUCT_PTR tr_ptr; if (pipe_ptr == NULL) { return; } usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle; USB_lock(); /* Cancel all active TR's in the pipe */ tr_ptr = pipe_ptr->tr_list_ptr; if (tr_ptr) { while (tr_ptr->TR_INDEX != 0) { tr_ptr->CALLBACK = NULL; /* no surprises */ /* Cancel the transfer at low-level */ status = _usb_host_cancel_call_interface (handle, pipe_ptr, tr_ptr); if (status != USB_OK) { } /* Indicate that the TR is idle */ tr_ptr->TR_INDEX = 0; tr_ptr->status = USB_STATUS_IDLE; tr_ptr = tr_ptr->next; } /* EndWhile */ } /* Endif */ /* zero the pipe descriptor, except keep TR list */ tr_ptr = pipe_ptr->tr_list_ptr; _usb_host_close_pipe(handle, (pointer)pipe_ptr); pipe_ptr->tr_list_ptr = tr_ptr; USB_unlock(); } /* EndBody */
/*FUNCTION*------------------------------------------------------------- * * Function Name : _usb_host_cancel_transfer * Returned Value : error or status of the transfer before cancellation * Comments : * _usb_host_cancel_transfer is a non-blocking routine that causes a transfer to * be terminated. * *END*-----------------------------------------------------------------*/ USB_STATUS _usb_host_cancel_transfer ( /* [IN] the USB Host state structure */ _usb_host_handle handle, /* [IN] the pipe handle */ _usb_pipe_handle pipe_handle, /* [IN] the transfer numnber for this pipe */ uint_32 tr_number ) { /* Body */ USB_HOST_STATE_STRUCT_PTR usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle; PIPE_STRUCT_PTR pipe_descr_ptr = (PIPE_STRUCT_PTR)pipe_handle; TR_STRUCT_PTR pipe_tr_ptr; USB_STATUS error; uint_32 bRet; #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("_usb_host_cancel_transfer"); #endif USB_lock(); /* Check if valid pipe id */ if (pipe_descr_ptr->PIPE_ID > USBCFG_MAX_PIPES) { USB_unlock(); #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("_usb_host_cancel_transfer, invalid pipe"); #endif return USB_log_error(__FILE__,__LINE__,USBERR_INVALID_PIPE_HANDLE); } /* Endif */ pipe_tr_ptr = pipe_descr_ptr->tr_list_ptr; while (pipe_tr_ptr->TR_INDEX != tr_number) { /* If unused TR found, or end of list, exit with bad status */ if ((pipe_tr_ptr->TR_INDEX == 0) || (pipe_tr_ptr->NEXT== pipe_descr_ptr->tr_list_ptr)) { USB_unlock(); #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("_usb_host_cancel_transfer, invalid pipe"); #endif return USB_log_error(__FILE__,__LINE__,USBERR_INVALID_PIPE_HANDLE); } /* EndIf */ pipe_tr_ptr = pipe_tr_ptr->NEXT; } /* EndWhile */ /* Get the current status */ bRet = pipe_tr_ptr->STATUS; /* Cancel the transfer at low-level */ error = _usb_host_cancel_call_interface (handle, pipe_descr_ptr, pipe_tr_ptr); if (error != USB_OK) { USB_unlock(); #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("_usb_host_cancel_transfer, FAILED"); #endif return USB_log_error(__FILE__,__LINE__,error); } /* Indicate that the pipe is idle */ pipe_tr_ptr->STATUS = USB_STATUS_IDLE; if (pipe_tr_ptr->CALLBACK != NULL) { pipe_tr_ptr->CALLBACK((pointer)pipe_descr_ptr, pipe_tr_ptr->CALLBACK_PARAM, NULL, 0, USBERR_SHUTDOWN); } /* Endif */ USB_unlock(); #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("_usb_host_cancel_transfer,SUCCESSFUL"); #endif /* Return the status prior to the transfer cancellation */ return bRet; } /* Endbody */
/*FUNCTION*---------------------------------------------------------------- * * Function Name : usb_dev_list_close_pipe * Returned Value : * Comments : * Cancel pending TR's and close a pipe. * *END*--------------------------------------------------------------------*/ static void usb_dev_list_close_pipe ( _usb_host_handle handle, PIPE_STRUCT_PTR pipe_ptr ) { /* Body */ USB_STATUS status; USB_HOST_STATE_STRUCT_PTR usb_host_ptr; TR_STRUCT_PTR tr_ptr; #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_close_pipe"); #endif if (pipe_ptr == NULL) { #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_close_pipe NULL pipe"); #endif return; } usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle; USB_lock(); /* Cancel all active TR's in the pipe */ tr_ptr = pipe_ptr->tr_list_ptr; if (tr_ptr != NULL) { do { //tr_ptr->CALLBACK = NULL; if (tr_ptr->TR_INDEX != 0) { tr_ptr->FLAG &= ~TR_CANCEL_ASYNC; /* Cancel the transfer at low-level */ status = _usb_host_cancel_call_interface(handle, pipe_ptr, tr_ptr); if (status != USB_OK) { #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_close_pipe failed to cancel transaction"); #endif } } tr_ptr->STATUS = USB_STATUS_IDLE; /* Indicate that the TR is idle */ tr_ptr->TR_INDEX = 0; tr_ptr = tr_ptr->NEXT; } while (tr_ptr != pipe_ptr->tr_list_ptr); //this indicates end of queue } /* EndWhile */ /* zero the pipe descriptor, except keep TR list */ tr_ptr = pipe_ptr->tr_list_ptr; _usb_host_close_pipe(handle, (pointer)pipe_ptr); pipe_ptr->tr_list_ptr = tr_ptr; USB_unlock(); #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_close_pipe SUCCESSFUL"); #endif } /* EndBody */