From 8cd076af1ebd0445c6bbe8daf0843e44bea2e404 Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Fri, 29 Nov 2013 17:11:55 -0500 Subject: [PATCH] fx3: Check return value of CyU3PDmaChannelSetXfer() We won't clear the EP halt (and possibly ACK) if this fails. This addresses CID 1097393 ("Unchecked return value") --- fx3_firmware/bladeRF.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fx3_firmware/bladeRF.c b/fx3_firmware/bladeRF.c index cd7f8943..0ad55b05 100644 --- a/fx3_firmware/bladeRF.c +++ b/fx3_firmware/bladeRF.c @@ -235,15 +235,22 @@ CyBool_t GetStatus(uint16_t endpoint) { return isHandled; } -void ClearDMAChannel(uint8_t ep, CyU3PDmaChannel * handle, uint32_t count, CyBool_t stall_only) { +void ClearDMAChannel(uint8_t ep, CyU3PDmaChannel * handle, uint32_t count, + CyBool_t stall_only) { + + CyU3PReturnStatus_t status; + CyU3PDmaChannelReset (handle); CyU3PUsbFlushEp(ep); CyU3PUsbResetEp(ep); - CyU3PDmaChannelSetXfer (handle, count); - CyU3PUsbStall (ep, CyFalse, CyTrue); + status = CyU3PDmaChannelSetXfer (handle, count); - if(!stall_only) { - CyU3PUsbAckSetup (); + if (status == CY_U3P_SUCCESS) { + CyU3PUsbStall (ep, CyFalse, CyTrue); + + if(!stall_only) { + CyU3PUsbAckSetup (); + } } }