GitLab has been upgraded to 13.3.6. If you encounter any issues mail code@riscosopen.org

Commit 39e2d3a4 authored by Jeffrey Lee's avatar Jeffrey Lee

Fix error handling when transfers fail to start

Detail:
  c/softc_device - Fix softc_device_start() to call usb_transfer_complete() with the appropriate status code if a transfer fails to start - returning the status to the caller isn't enough. Also tweak debug output and add extra safety checks to timeout cancellation.
Admin:
  Tested on Raspberry Pi


Version 0.19. Tagged as 'DWCDriver-0_19'
parent 1d60fab9
/* (0.18)
/* (0.19)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.18
#define Module_MajorVersion_CMHG 0.19
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 31 Oct 2014
#define Module_Date_CMHG 28 Mar 2015
#define Module_MajorVersion "0.18"
#define Module_Version 18
#define Module_MajorVersion "0.19"
#define Module_Version 19
#define Module_MinorVersion ""
#define Module_Date "31 Oct 2014"
#define Module_Date "28 Mar 2015"
#define Module_ApplicationDate "31-Oct-14"
#define Module_ApplicationDate "28-Mar-15"
#define Module_ComponentName "DWCDriver"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/USB/Controllers/DWCDriver"
#define Module_FullVersion "0.18"
#define Module_HelpVersion "0.18 (31 Oct 2014)"
#define Module_LibraryVersionInfo "0:18"
#define Module_FullVersion "0.19"
#define Module_HelpVersion "0.19 (28 Mar 2015)"
#define Module_LibraryVersionInfo "0:19"
......@@ -119,7 +119,7 @@ usbd_status softc_device_start(usbd_xfer_handle xfer)
void *buf = KERNADDR(&ex->xfer.dmabuf,0);
dwc_dma_t dma_addr = ((dwc_dma_t) vtophys(buf)) + dma_offset;
DPRINTF(("xfer len %08x\n",ex->xfer.length));
DPRINTF(("xfer len %08x buf %08x -> %08x\n",ex->xfer.length,buf,dma_addr));
/* Set urb parameters for this xfer */
......@@ -147,26 +147,38 @@ usbd_status softc_device_start(usbd_xfer_handle xfer)
dprintf(("","urb_enqueue failed, %d\n",ret));
if(timeout) {
callout_stop(&(ex->xfer.timeout_handle));
/* Just in case... */
riscos_cancel_abort_pipe(xfer);
}
}
DWC_SPINUNLOCK_IRQRESTORE(sc->dwc_dev.hcd->lock, irqflags);
if(!ret)
{
return USBD_IN_PROGRESS;
}
epipe->xfer = NULL;
/* If we've failed to start we must mark the request as complete, with the appropriate error code */
usbd_status err;
switch(ret)
{
case 0:
return USBD_IN_PROGRESS;
case -DWC_E_NO_DEVICE:
epipe->xfer = NULL;
return USBD_BAD_ADDRESS; /*?*/
err = USBD_BAD_ADDRESS; /*?*/
break;
case -DWC_E_NO_MEMORY:
epipe->xfer = NULL;
return USBD_NOMEM;
err = USBD_NOMEM;
break;
default:
epipe->xfer = NULL;
return USBD_IOERROR;
err = USBD_IOERROR;
break;
}
xfer->status = err;
usb_transfer_complete(xfer);
/* xfer may have been deleted now */
return err;
}
void softc_device_abort(usbd_xfer_handle xfer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment