diff mbox

[2/2] DSPBRIDGE: Reclaim all pending buffer on resource cleanup

Message ID 496565EC904933469F292DDA3F1663E602CA2B9606@dlee06.ent.ti.com (mailing list archive)
State Accepted
Delegated to:
Headers show

Commit Message

Guzman Lugo, Fernando Feb. 17, 2010, 12:40 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/dsp/bridge/rmgr/drv.c b/drivers/dsp/bridge/rmgr/drv.c
index 505f2b0..5a394da 100644
--- a/drivers/dsp/bridge/rmgr/drv.c
+++ b/drivers/dsp/bridge/rmgr/drv.c
@@ -461,6 +461,8 @@  DSP_STATUS DRV_RemoveAllSTRMResElements(HANDLE hPCtxt)
 	DSP_STATUS status = DSP_SOK;
 	struct STRM_RES_OBJECT *strm_res = NULL;
 	struct STRM_RES_OBJECT *strm_tmp = NULL;
+	struct STRM_INFO strm_info;
+	struct DSP_STREAMINFO user;
 	u8 **apBuffer = NULL;
 	u8 *pBufPtr;
 	u32 ulBytes;
@@ -474,17 +476,19 @@  DSP_STATUS DRV_RemoveAllSTRMResElements(HANDLE hPCtxt)
 		if (strm_res->uNumBufs) {
 			apBuffer = MEM_Alloc((strm_res->uNumBufs *
 					    sizeof(u8 *)), MEM_NONPAGED);
-			status = STRM_FreeBuffer(strm_res->hStream, apBuffer,
-						strm_res->uNumBufs, pCtxt);
-			kfree(apBuffer);
+			if (apBuffer) {
+				status = STRM_FreeBuffer(strm_res->hStream,
+					apBuffer, strm_res->uNumBufs, pCtxt);
+				kfree(apBuffer);
+			}
 		}
+		strm_info.pUser = &user;
+		user.uNumberBufsInStream = 0;
+		STRM_GetInfo(strm_res->hStream, &strm_info, sizeof(strm_info));
+		while (user.uNumberBufsInStream--)
+			STRM_Reclaim(strm_res->hStream, &pBufPtr, &ulBytes,
+					     (u32 *)&ulBufSize, &dwArg);
 		status = STRM_Close(strm_res->hStream, pCtxt);
-		if (status == DSP_EPENDING) {
-			status = STRM_Reclaim(strm_res->hStream,
-				&pBufPtr, &ulBytes, (u32 *)&ulBufSize, &dwArg);
-			if (DSP_SUCCEEDED(status))
-				status = STRM_Close(strm_res->hStream, pCtxt);
-		}
 	}
 	return status;
 }