PASDK-251: Free DMA resources (link params + error param, too; not just active channe...
authorGovind Jeyaram <govind.j@ti.com>
Wed, 5 Apr 2017 17:09:51 +0000 (10:09 -0700)
committerGovind Jeyaram <govind.j@ti.com>
Wed, 5 Apr 2017 17:09:51 +0000 (10:09 -0700)
pasdk/test_dsp/sap/sap.c

index 16187f0ad77227a0e70a8a40ebbf3c99842afd39..23eae4b8090f41e3e7ab32af9f393f91cae0eb17 100644 (file)
@@ -235,7 +235,7 @@ Int SAP_ctrl (DEV2_Handle device, Uns code, Arg arg)
 {
     SAP_DeviceExtension *pDevExt = (SAP_DeviceExtension *)device->object;
     const SAP_Params *pParams;
-    Int result = SIO2_OK;
+    Int i, result = SIO2_OK;
     EDMA3_DRV_Handle   hEdma;
     //TRACE_GEN((&TR_MOD, "SAP_ctrl.%d (0x%x) code = 0x%x", __LINE__, device, code));
 
@@ -285,10 +285,24 @@ Int SAP_ctrl (DEV2_Handle device, Uns code, Arg arg)
                                hEdma = hEdma0;
                        else if (pParams->sio.moduleNum == 1 || pParams->sio.moduleNum == 2)
                                hEdma = hEdma1;
+
             if (pDevExt->activeEdma != EDMA_HINV) {
                                EDMA3_DRV_freeChannel (hEdma, pDevExt->activeEdma);
-                            pDevExt->activeEdma = EDMA_HINV;
-                        }
+                               pDevExt->activeEdma = EDMA_HINV;
+                       }
+
+            for (i=0; i < pDevExt->numEdmaParams; i++) {
+               if (pDevExt->edmaParams[i].hEdmaParam != EDMA_HINV)
+               {
+                       EDMA3_DRV_freeChannel (hEdma, pDevExt->edmaParams[i].hEdmaParam);
+                       pDevExt->edmaParams[i].hEdmaParam = EDMA_HINV;
+               }
+            }
+
+            if (pDevExt->errorEdma != EDMA_HINV) {
+                               EDMA3_DRV_freeChannel (hEdma, pDevExt->errorEdma);
+                               pDevExt->errorEdma = EDMA_HINV;
+                       }
 
             if (!(pParams = pDevExt->pParams))
                 return SIO2_OK;