Skip to contentSkip to conversation

DSPBRIDGE: Return right error codes

PATCH Applied Omar Ramirez Luna 1 participant 5 messages Jan 19, 2010 – Jan 20, 2010

lore
Share & tools
lore
#0 lore raw

cover DSPBRIDGE: Return right error codes

This set of patches fixes the overwritten or missing error codes returned from different bridge layers.

Fernando Guzman Lugo (3):
DSPBRIDGE: return right error codes wmd directory
DSPBRIDGE: return right error codes services directory
DSPBRIDGE: return right error codes rmgr directory

 drivers/dsp/bridge/rmgr/dbdcd.c         |   31 ++--
 drivers/dsp/bridge/rmgr/disp.c          |   36 ++--
 drivers/dsp/bridge/rmgr/drv.c           |   89 +++++----
 drivers/dsp/bridge/rmgr/dspdrv.c        |   27 ++--
 drivers/dsp/bridge/rmgr/mgr.c           |   23 +--
 drivers/dsp/bridge/rmgr/nldr.c          |   32 +--
 drivers/dsp/bridge/rmgr/node.c          |  123 ++++++------
 drivers/dsp/bridge/rmgr/proc.c          |  100 ++++------
 drivers/dsp/bridge/rmgr/strm.c          |   31 +--
 drivers/dsp/bridge/services/cfg.c       |    8 +-
 drivers/dsp/bridge/services/clk.c       |    7 +-
 drivers/dsp/bridge/services/reg.c       |   25 +--
 drivers/dsp/bridge/services/sync.c      |    1 -
 drivers/dsp/bridge/wmd/chnl_sm.c        |  230 +++++++++++------------
 drivers/dsp/bridge/wmd/io_sm.c          |  322 ++++++++++++++-----------------
 drivers/dsp/bridge/wmd/mmu_fault.c      |    4 +-
 drivers/dsp/bridge/wmd/msg_sm.c         |   47 +++--
 drivers/dsp/bridge/wmd/tiomap3430.c     |   28 +--
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   10 +-
 drivers/dsp/bridge/wmd/tiomap_io.c      |   10 +-
 drivers/dsp/bridge/wmd/tiomap_sm.c      |    2 -
 drivers/dsp/bridge/wmd/ue_deh.c         |   21 +--
 22 files changed, 542 insertions(+), 665 deletions(-)
#1 lore raw

PATCH 1/3 DSPBRIDGE: return right error codes wmd directory

From: Fernando Guzman Lugo <[email protected]>

This patch fixes bad error codes returned by some functions, it validates status of previously unchecked functions and removes unused conditional statements or status variables.

---
 drivers/dsp/bridge/wmd/chnl_sm.c        |  230 +++++++++++------------
 drivers/dsp/bridge/wmd/io_sm.c          |  322 ++++++++++++++-----------------
 drivers/dsp/bridge/wmd/mmu_fault.c      |    4 +-
 drivers/dsp/bridge/wmd/msg_sm.c         |   47 +++--
 drivers/dsp/bridge/wmd/tiomap3430.c     |   28 +--
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   10 +-
 drivers/dsp/bridge/wmd/tiomap_io.c      |   10 +-
 drivers/dsp/bridge/wmd/tiomap_sm.c      |    2 -
 drivers/dsp/bridge/wmd/ue_deh.c         |   21 +--
 9 files changed, 308 insertions(+), 366 deletions(-)
drivers/dsp/bridge/wmd/chnl_sm.c +110 -120
index 867792e..ae2e3ec 100644
@@ -109,7 +109,34 @@ DSP_STATUS WMD_CHNL_AddIOReq(struct CHNL_OBJECT *hChnl, void *pHostBuf,
 		  "%x Id %d\n", pChnl, CHNL_IsOutput(pChnl->uMode),
 		  pChnl->uChnlType, pChnl->uId);
 
-	fIsEOS = (cBytes == 0) ? true : false;
+	fIsEOS = (cBytes == 0);
+
+	/* Validate args */
+	if (!pHostBuf) {
+		status = DSP_EPOINTER;
+	} else if (!MEM_IsValidHandle(pChnl, CHNL_SIGNATURE)) {
+		status = DSP_EHANDLE;
+	} else if (fIsEOS && CHNL_IsInput(pChnl->uMode)) {
+		status = CHNL_E_NOEOS;
+	} else {
+		/*
+		 * Check the channel state: only queue chirp if channel state
+		 * allows it.
+		 */
+		dwState = pChnl->dwState;
+		if (dwState != CHNL_STATEREADY) {
+			if (dwState & CHNL_STATECANCEL)
+				status = CHNL_E_CANCELLED;
+			else if ((dwState & CHNL_STATEEOS) &&
+						CHNL_IsOutput(pChnl->uMode))
+				status = CHNL_E_EOS;
+			else
+				/* No other possible states left */
+				DBC_Assert(0);
+		}
+	}
+	if (DSP_FAILED(status))
+		goto func_end;
 
 	if (pChnl->uChnlType == CHNL_PCPY && pChnl->uId > 1 && pHostBuf) {
 		if (!(pHostBuf < (void *)USERMODE_ADDR)) {
@@ -122,7 +149,7 @@ DSP_STATUS WMD_CHNL_AddIOReq(struct CHNL_OBJECT *hChnl, void *pHostBuf,
 			status = DSP_EMEMORY;
 			DBG_Trace(DBG_LEVEL7,
 				 "No memory to allocate kernel buffer\n");
-			goto func_cont;
+			goto func_end;
 		}
 		if (CHNL_IsOutput(pChnl->uMode)) {
 			status = copy_from_user(pHostSysBuf, pHostBuf,
@@ -135,33 +162,11 @@ DSP_STATUS WMD_CHNL_AddIOReq(struct CHNL_OBJECT *hChnl, void *pHostBuf,
 				MEM_Free(pHostSysBuf);
 				pHostSysBuf = NULL;
 				status = DSP_EPOINTER;
+				goto func_end;
 			}
 		}
 	}
 func_cont:
-	/* Validate args:  */
-	if (pHostBuf == NULL) {
-		status = DSP_EPOINTER;
-	} else if (!MEM_IsValidHandle(pChnl, CHNL_SIGNATURE)) {
-		status = DSP_EHANDLE;
-	} else if (fIsEOS && CHNL_IsInput(pChnl->uMode)) {
-		status = CHNL_E_NOEOS;
-	} else {
-		/* Check the channel state: only queue chirp if channel state
-		 * allows */
-		dwState = pChnl->dwState;
-		if (dwState != CHNL_STATEREADY) {
-			if (dwState & CHNL_STATECANCEL) {
-				status = CHNL_E_CANCELLED;
-			} else if ((dwState & CHNL_STATEEOS)
-				   && CHNL_IsOutput(pChnl->uMode)) {
-				status = CHNL_E_EOS;
-			} else {
-				/* No other possible states left: */
-				DBC_Assert(0);
-			}
-		}
-	}
 	/* Mailbox IRQ is disabled to avoid race condition with DMA/ZCPY
 	 * channels. DPCCS is held to avoid race conditions with PCPY channels.
 	 * If DPC is scheduled in process context (IO_Schedule) and any
@@ -191,47 +196,49 @@ func_cont:
 		if (pChnl->uChnlType == CHNL_PCPY && pChnl->uId > 1)
 			pChirp->pHostSysBuf = pHostSysBuf;
 
-		if (DSP_SUCCEEDED(status)) {
-			/* Note: for dma chans dwDspAddr contains dsp address
-			 * of SM buffer.*/
-			DBC_Assert(pChnlMgr->uWordSize != 0);
-			/* DSP address */
-			pChirp->uDspAddr = dwDspAddr / pChnlMgr->uWordSize;
-			pChirp->cBytes = cBytes;
-			pChirp->cBufSize = cBufSize;
-			/* Only valid for output channel */
-			pChirp->dwArg = dwArg;
-			pChirp->status = (fIsEOS ? CHNL_IOCSTATEOS :
-					 CHNL_IOCSTATCOMPLETE);
-			LST_PutTail(pChnl->pIORequests, (struct LST_ELEM *)
-				   pChirp);
-			pChnl->cIOReqs++;
-			DBC_Assert(pChnl->cIOReqs <= pChnl->cChirps);
-			/* If end of stream, update the channel state to prevent
-			 * more IOR's: */
-			if (fIsEOS)
-				pChnl->dwState |= CHNL_STATEEOS;
+		/*
+		 * Note: for dma chans dwDspAddr contains dsp address
+		 * of SM buffer.
+		 */
+		DBC_Assert(pChnlMgr->uWordSize != 0);
+		/* DSP address */
+		pChirp->uDspAddr = dwDspAddr / pChnlMgr->uWordSize;
+		pChirp->cBytes = cBytes;
+		pChirp->cBufSize = cBufSize;
+		/* Only valid for output channel */
+		pChirp->dwArg = dwArg;
+		pChirp->status = (fIsEOS ? CHNL_IOCSTATEOS :
+						CHNL_IOCSTATCOMPLETE);
+		LST_PutTail(pChnl->pIORequests, (struct LST_ELEM *)pChirp);
+		pChnl->cIOReqs++;
+		DBC_Assert(pChnl->cIOReqs <= pChnl->cChirps);
+		/*
+		 * If end of stream, update the channel state to prevent
+		 * more IOR's.
+		 */
+		if (fIsEOS)
+			pChnl->dwState |= CHNL_STATEEOS;
+
+		/* Legacy DSM Processor-Copy */
+		DBC_Assert(pChnl->uChnlType == CHNL_PCPY);
+		/* Request IO from the DSP */
+		IO_RequestChnl(pChnlMgr->hIOMgr, pChnl,
+			(CHNL_IsInput(pChnl->uMode) ? IO_INPUT : IO_OUTPUT),
+								&wMbVal);
+		fSchedDPC = true;
+
 
-			{
-				/* Legacy DSM Processor-Copy */
-				DBC_Assert(pChnl->uChnlType == CHNL_PCPY);
-				/* Request IO from the DSP */
-				IO_RequestChnl(pChnlMgr->hIOMgr, pChnl,
-					(CHNL_IsInput(pChnl->uMode) ?
-					IO_INPUT : IO_OUTPUT), &wMbVal);
-				fSchedDPC = true;
-			}
-		}
 	}
 	enable_irq(MAILBOX_IRQ);
 	SYNC_LeaveCS(pChnlMgr->hCSObj);
 	if (wMbVal != 0)
 		IO_IntrDSP2(pChnlMgr->hIOMgr, wMbVal);
 
-	if (fSchedDPC == true) {
-		/* Schedule a DPC, to do the actual data transfer: */
+	/* Schedule a DPC, to do the actual data transfer */
+	if (fSchedDPC)
 		IO_Schedule(pChnlMgr->hIOMgr);
-	}
+
+func_end:
 	DBG_Trace(DBG_ENTER, "< WMD_CHNL_AddIOReq pChnl %p\n", pChnl);
 	return status;
 }
@@ -382,58 +389,49 @@ DSP_STATUS WMD_CHNL_Create(OUT struct CHNL_MGR **phChnlMgr,
 	DSP_STATUS status = DSP_SOK;
 	struct CHNL_MGR *pChnlMgr = NULL;
 	s32 cChannels;
-#ifdef DEBUG
-	struct CHNL_MGR *hChnlMgr;
-#endif
+
 	/* Check DBC requirements:  */
 	DBC_Require(phChnlMgr != NULL);
 	DBC_Require(pMgrAttrs != NULL);
 	DBC_Require(pMgrAttrs->cChannels > 0);
 	DBC_Require(pMgrAttrs->cChannels <= CHNL_MAXCHANNELS);
 	DBC_Require(pMgrAttrs->uWordSize != 0);
-#ifdef DEBUG
-	/* This for the purposes of DBC_Require: */
-	status = DEV_GetChnlMgr(hDevObject, &hChnlMgr);
-	DBC_Require(status != DSP_EHANDLE);
-	DBC_Require(hChnlMgr == NULL);
-#endif
-	if (DSP_SUCCEEDED(status)) {
-		/* Allocate channel manager object: */
-		MEM_AllocObject(pChnlMgr, struct CHNL_MGR, CHNL_MGRSIGNATURE);
-		if (pChnlMgr) {
-			/* The cChannels attr must equal the # of supported
-			 * chnls for each transport(# chnls for PCPY = DDMA =
-			 * ZCPY): i.e. pMgrAttrs->cChannels = CHNL_MAXCHANNELS =
-			 * DDMA_MAXDDMACHNLS = DDMA_MAXZCPYCHNLS.  */
-			DBC_Assert(pMgrAttrs->cChannels == CHNL_MAXCHANNELS);
-			cChannels = (CHNL_MAXCHANNELS + (CHNL_MAXCHANNELS *
-				    CHNL_PCPY));
-			/* Create array of channels: */
-			pChnlMgr->apChannel = MEM_Calloc(
-						sizeof(struct CHNL_OBJECT *) *
-						cChannels, MEM_NONPAGED);
-			if (pChnlMgr->apChannel) {
-				/* Initialize CHNL_MGR object: */
-				/* Shared memory driver. */
-				pChnlMgr->dwType = CHNL_TYPESM;
-				pChnlMgr->uWordSize = pMgrAttrs->uWordSize;
-				/* total # chnls supported */
-				pChnlMgr->cChannels = cChannels;
-				pChnlMgr->cOpenChannels = 0;
-				pChnlMgr->dwOutputMask = 0;
-				pChnlMgr->dwLastOutput = 0;
-				pChnlMgr->hDevObject = hDevObject;
-				if (DSP_SUCCEEDED(status)) {
-					status = SYNC_InitializeDPCCS
-						(&pChnlMgr->hCSObj);
-				}
-			} else {
-				status = DSP_EMEMORY;
-			}
+
+	/* Allocate channel manager object */
+	MEM_AllocObject(pChnlMgr, struct CHNL_MGR, CHNL_MGRSIGNATURE);
+	if (pChnlMgr) {
+		/*
+		 * The cChannels attr must equal the # of supported chnls for
+		 * each transport(# chnls for PCPY = DDMA = ZCPY): i.e.
+		 * 	pMgrAttrs->cChannels = CHNL_MAXCHANNELS =
+		 * 			 DDMA_MAXDDMACHNLS = DDMA_MAXZCPYCHNLS.
+		 */
+		DBC_Assert(pMgrAttrs->cChannels == CHNL_MAXCHANNELS);
+		cChannels = CHNL_MAXCHANNELS + CHNL_MAXCHANNELS * CHNL_PCPY;
+		/* Create array of channels */
+		pChnlMgr->apChannel = MEM_Calloc(
+				sizeof(struct CHNL_OBJECT *) *
+				cChannels, MEM_NONPAGED);
+		if (pChnlMgr->apChannel) {
+			/* Initialize CHNL_MGR object */
+			pChnlMgr->dwType = CHNL_TYPESM;
+			pChnlMgr->uWordSize = pMgrAttrs->uWordSize;
+			/* Total # chnls supported */
+			pChnlMgr->cChannels = cChannels;
+			pChnlMgr->cOpenChannels = 0;
+			pChnlMgr->dwOutputMask = 0;
+			pChnlMgr->dwLastOutput = 0;
+			pChnlMgr->hDevObject = hDevObject;
+			if (DSP_SUCCEEDED(status))
+				status = SYNC_InitializeDPCCS(
+							&pChnlMgr->hCSObj);
 		} else {
 			status = DSP_EMEMORY;
 		}
+	} else {
+		status = DSP_EMEMORY;
 	}
+
 	if (DSP_FAILED(status)) {
 		WMD_CHNL_Destroy(pChnlMgr);
 		*phChnlMgr = NULL;
@@ -458,10 +456,10 @@ DSP_STATUS WMD_CHNL_Destroy(struct CHNL_MGR *hChnlMgr)
 	if (MEM_IsValidHandle(hChnlMgr, CHNL_MGRSIGNATURE)) {
 		/* Close all open channels: */
 		for (iChnl = 0; iChnl < pChnlMgr->cChannels; iChnl++) {
-			if (DSP_SUCCEEDED
-			    (WMD_CHNL_Close(pChnlMgr->apChannel[iChnl]))) {
-				DBC_Assert(pChnlMgr->apChannel[iChnl] == NULL);
-			}
+			status = WMD_CHNL_Close(pChnlMgr->apChannel[iChnl]);
+			if (DSP_FAILED(status))
+				DBG_Trace(DBG_LEVEL7, "Error in CHNL_Close "
+						"status 0x%x\n", status);
 		}
 		/* release critical section */
 		if (pChnlMgr->hCSObj)
@@ -804,6 +802,7 @@ DSP_STATUS WMD_CHNL_Open(OUT struct CHNL_OBJECT **phChnl,
 	/* Ensure DBC requirements:  */
 	DBC_Require(phChnl != NULL);
 	DBC_Require(pAttrs != NULL);
+	DBC_Require(hChnlMgr != NULL);
 	*phChnl = NULL;
 	/* Validate Args:  */
 	if (pAttrs->uIOReqs == 0) {
@@ -813,12 +812,10 @@ DSP_STATUS WMD_CHNL_Open(OUT struct CHNL_OBJECT **phChnl,
 			status = DSP_EHANDLE;
 		} else {
 			if (uChnlId != CHNL_PICKFREE) {
-				if (uChnlId >= pChnlMgr->cChannels) {
+				if (uChnlId >= pChnlMgr->cChannels)
 					status = CHNL_E_BADCHANID;
-				} else if (pChnlMgr->apChannel[uChnlId] !=
-					  NULL) {
+				else if (pChnlMgr->apChannel[uChnlId] != NULL)
 					status = CHNL_E_CHANBUSY;
-				}
 			} else {
 				/* Check for free channel */
 				status = SearchFreeChannel(pChnlMgr, &uChnlId);
@@ -833,7 +830,7 @@ DSP_STATUS WMD_CHNL_Open(OUT struct CHNL_OBJECT **phChnl,
 	MEM_AllocObject(pChnl, struct CHNL_OBJECT, 0x0000);
 	if (!pChnl) {
 		status = DSP_EMEMORY;
-		goto func_cont;
+		goto func_end;
 	}
 	/* Protect queues from IO_DPC: */
 	pChnl->dwState = CHNL_STATECANCEL;
@@ -845,13 +842,9 @@ DSP_STATUS WMD_CHNL_Open(OUT struct CHNL_OBJECT **phChnl,
 	pChnl->cIOCs = 0;
 	pChnl->cIOReqs = 0;
 	status = SYNC_OpenEvent(&hSyncEvent, pSyncAttrs);
-	if (DSP_SUCCEEDED(status)) {
+	if (DSP_SUCCEEDED(status))
 		status = NTFY_Create(&pChnl->hNtfy);
-		if (DSP_FAILED(status)) {
-			/* The only failure that could have occurred */
-			status = DSP_EMEMORY;
-		}
-	}
+
 	if (DSP_SUCCEEDED(status)) {
 		if (pChnl->pIOCompletions && pChnl->pIORequests &&
 		   pChnl->pFreeList) {
@@ -870,9 +863,8 @@ DSP_STATUS WMD_CHNL_Open(OUT struct CHNL_OBJECT **phChnl,
 		} else {
 			status = DSP_EMEMORY;
 		}
-	} else {
-		status = DSP_EINVALIDARG;
 	}
+
 	if (DSP_FAILED(status)) {
 		/* Free memory */
 		if (pChnl->pIOCompletions) {
@@ -897,9 +889,7 @@ DSP_STATUS WMD_CHNL_Open(OUT struct CHNL_OBJECT **phChnl,
 			pChnl->hNtfy = NULL;
 		}
 		MEM_FreeObject(pChnl);
-	}
-func_cont:
-	if (DSP_SUCCEEDED(status)) {
+	} else {
 		/* Insert channel object in channel manager: */
 		pChnlMgr->apChannel[pChnl->uId] = pChnl;
 		SYNC_EnterCS(pChnlMgr->hCSObj);
drivers/dsp/bridge/wmd/io_sm.c +148 -174

443 lines not on this page · raw message

drivers/dsp/bridge/wmd/mmu_fault.c +2 -2
index ef6ea77..14ca490 100644
@@ -77,7 +77,7 @@ irqreturn_t  MMU_FaultIsr(int irq, IN void *pRefData)
 	DSP_STATUS status = DSP_SOK;
 
 	DBG_Trace(DBG_LEVEL1, "Entering DEH_DspMmuIsr: 0x%x\n", pRefData);
-       DBC_Require(irq == INT_DSP_MMU_IRQ);
+	DBC_Require(irq == INT_DSP_MMU_IRQ);
 	DBC_Require(MEM_IsValidHandle(pDehMgr, SIGNATURE));
 
 	if (MEM_IsValidHandle(pDehMgr, SIGNATURE)) {
@@ -119,7 +119,7 @@ irqreturn_t  MMU_FaultIsr(int irq, IN void *pRefData)
 					    HW_MMU_ALL_INTERRUPTS);
 		}
 	}
-       return IRQ_HANDLED;
+	return IRQ_HANDLED;
 }
 
 
drivers/dsp/bridge/wmd/msg_sm.c +25 -22

67 lines not on this page · raw message

drivers/dsp/bridge/wmd/tiomap3430.c +8 -20
index 4729ae5..2411917 100644
@@ -591,13 +591,11 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 				}
 			}
 
-			if (clkIdIndex < MBX_PM_MAX_RESOURCES)
+			if (clkIdIndex < MBX_PM_MAX_RESOURCES) {
 				status =
 				    CLK_Set_32KHz(BPWR_Clks[clkIdIndex].funClk);
-			else
+			} else {
 				status = DSP_EFAIL;
-
-			if (DSP_FAILED(status)) {
 				DBG_Trace(DBG_LEVEL7, " Error while setting"
 							"LM Timer  to 32KHz\n");
 			}
@@ -633,13 +631,11 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 				}
 			}
 
-			if (clkIdIndex < MBX_PM_MAX_RESOURCES)
+			if (clkIdIndex < MBX_PM_MAX_RESOURCES) {
 				status = CLK_Set_32KHz(
 						BPWR_Clks[clkIdIndex].funClk);
-			else
+			} else {
 				status = DSP_EFAIL;
-
-			if (DSP_FAILED(status)) {
 				DBG_Trace(DBG_LEVEL7,
 				" Error while setting BIOS Timer  to 32KHz\n");
 			}
@@ -708,9 +704,7 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 		/* Enable Mailbox events and also drain any pending
 		 * stale messages */
 		(void)CHNLSM_EnableInterrupt(pDevContext);
-	}
 
-	if (DSP_SUCCEEDED(status)) {
 		HW_RSTCTRL_RegGet(resources.dwPrmBase, HW_RST1_IVA2, &temp);
 		DBG_Trace(DBG_LEVEL7, "BRD_Start: RM_RSTCTRL_DSP = 0x%x \n",
 				temp);
@@ -738,10 +732,8 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 				dwDSPAddr);
 		if (dsp_debug)
 			while (*((volatile u16 *)dwSyncAddr))
-				;;
-	}
+				;
 
-	if (DSP_SUCCEEDED(status)) {
 		/* Wait for DSP to clear word in shared memory */
 		/* Read the Location */
 		if (!WaitForStart(pDevContext, dwSyncAddr)) {
@@ -758,8 +750,7 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 			 * completion of OPP table update to DSP
 			 */
 			*((volatile u32 *)dwSyncAddr) = 0XCAFECAFE;
-		}
-		if (DSP_SUCCEEDED(status)) {
+
 			/* update board state */
 			pDevContext->dwBrdState = BRD_RUNNING;
 			/* (void)CHNLSM_EnableInterrupt(pDevContext);*/
@@ -2048,9 +2039,7 @@ void configureDspMmu(struct WMD_DEV_CONTEXT *pDevContext, u32 dataBasePhys,
 		    enum HW_ElementSize_t elemSize,
 		    enum HW_MMUMixedSize_t mixedSize)
 {
-	struct CFG_HOSTRES resources;
 	struct HW_MMUMapAttrs_t mapAttrs = { endianism, elemSize, mixedSize };
-	DSP_STATUS status = DSP_SOK;
 
 	DBC_Require(sizeInBytes > 0);
 	DBG_Trace(DBG_LEVEL1,
@@ -2059,9 +2048,8 @@ void configureDspMmu(struct WMD_DEV_CONTEXT *pDevContext, u32 dataBasePhys,
 
 	DBG_Trace(DBG_LEVEL1, "endianism %x, elemSize %x, mixedSize %x\n",
 		 endianism, elemSize, mixedSize);
-	status = CFG_GetHostResources(
-		 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
-	status = HW_MMU_TLBAdd(pDevContext->dwDSPMmuBase, dataBasePhys,
+
+	HW_MMU_TLBAdd(pDevContext->dwDSPMmuBase, dataBasePhys,
 				dspBaseVirt, sizeInBytes, nEntryStart,
 				&mapAttrs, HW_SET, HW_SET);
 }
drivers/dsp/bridge/wmd/tiomap3430_pwr.c +5 -5
index 4effe0c..084f406 100644
@@ -492,13 +492,15 @@ DSP_STATUS PreScale_DSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
  */
 DSP_STATUS PostScale_DSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 {
+	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_BRIDGE_DVFS
 	u32 level;
 	u32 voltage_domain;
 	struct IO_MGR *hIOMgr;
-	DSP_STATUS status = DSP_SOK;
 
 	status = DEV_GetIOMgr(pDevContext->hDevObject, &hIOMgr);
+	if (!hIOMgr)
+		return DSP_EHANDLE;
 
 	voltage_domain = *((u32 *)pArgs);
 	level = *((u32 *)pArgs + 1);
@@ -513,7 +515,6 @@ DSP_STATUS PostScale_DSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 		DBG_Trace(DBG_LEVEL7,
 			 "PostScale_DSP: IVA in sleep. Wrote to shared "
 			 "memory \n");
-		return DSP_SOK;
 	} else  if ((pDevContext->dwBrdState == BRD_RUNNING)) {
 		/* Update the OPP value in shared memory */
 		IO_SHMsetting(hIOMgr, SHM_CURROPP, &level);
@@ -522,14 +523,13 @@ DSP_STATUS PostScale_DSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 		DBG_Trace(DBG_LEVEL7,
 			"PostScale_DSP: Wrote to shared memory Sent post"
 			" notification to DSP\n");
-		return DSP_SOK;
 	} else {
 		DBG_Trace(DBG_LEVEL7, "PostScale_DSP: Failed - DSP BRD state "
 			"in wrong state");
-		return DSP_EFAIL;
+		status = DSP_EFAIL;
 	}
 #endif /* #ifdef CONFIG_BRIDGE_DVFS */
-	return DSP_SOK;
+	return status;
 }
 
 /*
drivers/dsp/bridge/wmd/tiomap_io.c +6 -4
index 33cf876..f60b8db 100644
@@ -78,7 +78,7 @@ DSP_STATUS ReadExtDspData(struct WMD_DEV_CONTEXT *hDevContext,
 	DBC_Assert(ulShmBaseVirt != 0);
 
 	/* Check if it is a read of Trace section */
-	if (!ulTraceSecBeg) {
+	if (DSP_SUCCEEDED(status) && !ulTraceSecBeg) {
 		status = DEV_GetSymbol(pDevContext->hDevObject,
 		DSP_TRACESEC_BEG, &ulTraceSecBeg);
 	}
@@ -100,7 +100,7 @@ DSP_STATUS ReadExtDspData(struct WMD_DEV_CONTEXT *hDevContext,
 	}
 
 	/* If reading from TRACE, force remap/unmap */
-	if ((bTraceRead) && dwBaseAddr) {
+	if (bTraceRead && dwBaseAddr) {
 		dwBaseAddr = 0;
 		pDevContext->dwDspExtBaseAddr = 0;
 	}
@@ -212,6 +212,9 @@ DSP_STATUS WriteDspData(struct WMD_DEV_CONTEXT *hDevContext, IN u8 *pbHostBuf,
 	status =  CFG_GetHostResources(
 		 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
 
+	if (DSP_FAILED(status))
+		return status;
+
 	offset = dwDSPAddr - hDevContext->dwDSPStartAdd;
 	if (offset < base1) {
 		dwBaseAddr = MEM_LinearAddress(resources.dwMemBase[2],
@@ -226,8 +229,7 @@ DSP_STATUS WriteDspData(struct WMD_DEV_CONTEXT *hDevContext, IN u8 *pbHostBuf,
 						resources.dwMemLength[4]);
 		offset = offset - base3;
 	} else{
-		status = DSP_EFAIL;
-		return status;
+		return DSP_EFAIL;
 	}
 	if (ulNumBytes)
 		memcpy((u8 *) (dwBaseAddr+offset), pbHostBuf, ulNumBytes);
drivers/dsp/bridge/wmd/tiomap_sm.c +0 -2
index 84e10ea..b04ed6d 100644
@@ -40,7 +40,6 @@ DSP_STATUS CHNLSM_EnableInterrupt(struct WMD_DEV_CONTEXT *pDevContext)
 	u32 mbxValue;
 	struct CFG_HOSTRES resources;
 	u32 devType;
-	struct IO_MGR *hIOMgr;
 
 	DBG_Trace(DBG_ENTER, "CHNLSM_EnableInterrupt(0x%x)\n", pDevContext);
 
@@ -49,7 +48,6 @@ DSP_STATUS CHNLSM_EnableInterrupt(struct WMD_DEV_CONTEXT *pDevContext)
 	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
 			     &resources);
 	DEV_GetDevType(pDevContext->hDevObject, &devType);
-	status = DEV_GetIOMgr(pDevContext->hDevObject, &hIOMgr);
 	if (devType == DSP_UNIT) {
 		HW_MBOX_NumMsgGet(resources.dwMboxBase,
 				  MBOX_DSP2ARM, &numMbxMsg);
drivers/dsp/bridge/wmd/ue_deh.c +4 -17
index daf75b6..6166d97 100644
@@ -86,8 +86,7 @@ DSP_STATUS WMD_DEH_Create(OUT struct DEH_MGR **phDehMgr,
 		status = DSP_EMEMORY;
 	} else {
 		/* Create an NTFY object to manage notifications */
-		if (DSP_SUCCEEDED(status))
-			status = NTFY_Create(&pDehMgr->hNtfy);
+		status = NTFY_Create(&pDehMgr->hNtfy);
 
 		/* Create a MMUfault DPC */
 		tasklet_init(&pDehMgr->dpc_tasklet, MMU_FaultDpc, (u32)pDehMgr);
@@ -188,7 +187,6 @@ void WMD_DEH_Notify(struct DEH_MGR *hDehMgr, u32 ulEventMask,
 	struct DEH_MGR *pDehMgr = (struct DEH_MGR *)hDehMgr;
 	struct WMD_DEV_CONTEXT *pDevContext;
 	DSP_STATUS status = DSP_SOK;
-	DSP_STATUS status1 = DSP_EFAIL;
 	u32 memPhysical = 0;
 	u32 HW_MMU_MAX_TLB_COUNT = 31;
 	u32 extern faultAddr;
@@ -287,16 +285,8 @@ DBG_Trace(DBG_LEVEL6, "WMD_DEH_Notify: DSP_MMUFAULT, "
 		}
 
 		/* Filter subsequent notifications when an error occurs */
-		if (pDevContext->dwBrdState != BRD_ERROR) {
-			/* Use it as a flag to send notifications the
-			 * first time and error occurred, next time
-			 * state will be BRD_ERROR */
-			status1 = DSP_EFAIL;
-		}
-
-		/* Filter subsequent notifications when an error occurs */
 		if (pDevContext->dwBrdState != BRD_ERROR)
-			status1 = DSP_SOK;
+			NTFY_Notify(pDehMgr->hNtfy, ulEventMask);
 
 		/* Set the Board state as ERROR */
 		pDevContext->dwBrdState = BRD_ERROR;
@@ -305,11 +295,6 @@ DBG_Trace(DBG_LEVEL6, "WMD_DEH_Notify: DSP_MMUFAULT, "
 		/* Call DSP Trace Buffer */
 		PrintDspTraceBuffer(hDehMgr->hWmdContext);
 
-		if (DSP_SUCCEEDED(status1)) {
-			/* Signal DSP error/exception event. */
-			NTFY_Notify(pDehMgr->hNtfy, ulEventMask);
-		}
-
 	}
 	DBG_Trace(DBG_LEVEL1, "Exiting WMD_DEH_Notify\n");
 
@@ -337,6 +322,8 @@ DSP_STATUS WMD_DEH_GetInfo(struct DEH_MGR *hDehMgr,
 		pErrInfo->dwVal1 = pDehMgr->errInfo.dwVal1;
 		pErrInfo->dwVal2 = pDehMgr->errInfo.dwVal2;
 		pErrInfo->dwVal3 = pDehMgr->errInfo.dwVal3;
+	} else {
+		status = DSP_EHANDLE;
 	}
 
 	DBG_Trace(DBG_LEVEL1, "Exiting WMD_DEH_GetInfo\n");
Signature · 1 line
1.6.2.4
#2 lore raw

PATCH 2/3 DSPBRIDGE: return right error codes services directory

From: Fernando Guzman Lugo <[email protected]>

This patch fixes bad error codes returned by some functions, it validates status of previously unchecked functions and removes unused conditional statements or status variables.

---
 drivers/dsp/bridge/services/cfg.c  |    8 +++++---
 drivers/dsp/bridge/services/clk.c  |    7 ++-----
 drivers/dsp/bridge/services/reg.c  |   25 ++++++++++---------------
 drivers/dsp/bridge/services/sync.c |    1 -
 4 files changed, 17 insertions(+), 24 deletions(-)
drivers/dsp/bridge/services/cfg.c +5 -3
index 72b7aae..4cdc4a3 100644
@@ -195,8 +195,7 @@ DSP_STATUS CFG_GetExecFile(struct CFG_DEVNODE *hDevNode, u32 ulBufSize,
 		  ulBufSize, pstrExecFile);
 	if (!hDevNode)
 		status = CFG_E_INVALIDHDEVNODE;
-
-	if (!pstrExecFile)
+	else if (!pstrExecFile)
 		status = CFG_E_INVALIDPOINTER;
 
 	if (DSP_SUCCEEDED(status)) {
@@ -278,9 +277,13 @@ DSP_STATUS CFG_GetObject(OUT u32 *pdwValue, u32 dwType)
 	switch (dwType) {
 	case (REG_DRV_OBJECT):
 		status = REG_GetValue(DRVOBJECT, (u8 *)pdwValue, &dwBufSize);
+		if (DSP_FAILED(status))
+			status = CFG_E_RESOURCENOTAVAIL;
 		break;
 	case (REG_MGR_OBJECT):
 		status = REG_GetValue(MGROBJECT, (u8 *)pdwValue, &dwBufSize);
+		if (DSP_FAILED(status))
+			status = CFG_E_RESOURCENOTAVAIL;
 		break;
 	default:
 		break;
@@ -290,7 +293,6 @@ DSP_STATUS CFG_GetObject(OUT u32 *pdwValue, u32 dwType)
 			  "CFG_GetObject SUCCESS DrvObject: "
 			  "0x%x\n ", *pdwValue);
 	} else {
-		status = CFG_E_RESOURCENOTAVAIL;
 		*pdwValue = 0;
 		GT_0trace(CFG_debugMask, GT_6CLASS, "CFG_GetObject Failed \n");
 	}
drivers/dsp/bridge/services/clk.c +2 -5
index c8de4e8..1be25cd 100644
@@ -178,9 +178,7 @@ DSP_STATUS CLK_Enable(IN enum SERVICES_ClkId clk_id)
 
 	pClk = SERVICES_Clks[clk_id].clk_handle;
 	if (pClk) {
-		if (clk_enable(pClk) == 0x0) {
-			/* Success ? */
-		} else {
+		if (clk_enable(pClk)) {
 			pr_err("CLK_Enable: failed to Enable CLK %s, "
 					"CLK dev id = %d\n",
 					SERVICES_Clks[clk_id].clk_name,
@@ -214,8 +212,7 @@ DSP_STATUS CLK_Set_32KHz(IN enum SERVICES_ClkId clk_id)
 	DSP_STATUS status = DSP_SOK;
 	struct clk *pClk;
 	struct clk *pClkParent;
-	enum SERVICES_ClkId sys_32k_id = SERVICESCLK_sys_32k_ck;
-	pClkParent =  SERVICES_Clks[sys_32k_id].clk_handle;
+	pClkParent =  SERVICES_Clks[SERVICESCLK_sys_32k_ck].clk_handle;
 
 	DBC_Require(clk_id < SERVICESCLK_NOT_DEFINED);
 	GT_2trace(CLK_debugMask, GT_6CLASS, "CLK_Set_32KHz: CLK %s, "
drivers/dsp/bridge/services/reg.c +10 -15
index d707289..7a375be 100644
@@ -47,15 +47,11 @@ struct GT_Mask REG_debugMask = { NULL, NULL };	/* GT trace var. */
 DSP_STATUS REG_DeleteValue(IN CONST char *pstrValue)
 {
 	DSP_STATUS status;
-	DBC_Require(pstrValue);
-       DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH);
+	DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH);
 
 	GT_0trace(REG_debugMask, GT_ENTER, "REG_DeleteValue: entered\n");
 
-	if (regsupDeleteValue(pstrValue) == DSP_SOK)
-		status = DSP_SOK;
-	else
-		status = DSP_EFAIL;
+	status = regsupDeleteValue(pstrValue);
 
 	return status;
 }
@@ -150,15 +146,14 @@ DSP_STATUS REG_SetValue(IN CONST char *pstrValue, IN u8 *pbData,
 
 	DBC_Require(pstrValue && pbData);
 	DBC_Require(dwDataSize > 0);
-       DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH);
-
-	/*  We need to use regsup calls...  */
-	/*  ...for now we don't need the key handle or  */
-	/*  the subkey, all we need is the value to lookup.  */
-	if (regsupSetValue((char *)pstrValue, pbData, dwDataSize) == DSP_SOK)
-		status = DSP_SOK;
-	else
-		status = DSP_EFAIL;
+	DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH);
+
+	/*
+	 * We need to use regsup calls
+	 * for now we don't need the key handle or
+	 * the subkey, all we need is the value to lookup.
+	 */
+	status = regsupSetValue((char *)pstrValue, pbData, dwDataSize);
 
 	return status;
 }
drivers/dsp/bridge/services/sync.c +0 -1
index c2d79c7..c76c23b 100644
@@ -187,7 +187,6 @@ DSP_STATUS SYNC_ResetEvent(struct SYNC_OBJECT *hEvent)
 
 	if (MEM_IsValidHandle(hEvent, SIGNATURE)) {
 		pEvent->state = so_reset;
-		status = DSP_SOK;
 	} else {
 		status = DSP_EHANDLE;
 		GT_1trace(SYNC_debugMask, GT_6CLASS,
Signature · 1 line
1.6.2.4
#3 lore raw

PATCH 3/3 DSPBRIDGE: return right error codes rmgr directory

From: Fernando Guzman Lugo <[email protected]>

This patch fixes bad error codes returned by some functions, it validates status of previously unchecked functions and removes unused conditional statements or status variables.

---
 drivers/dsp/bridge/rmgr/dbdcd.c  |   31 ++++------
 drivers/dsp/bridge/rmgr/disp.c   |   36 +++++------
 drivers/dsp/bridge/rmgr/drv.c    |   89 ++++++++++++++-------------
 drivers/dsp/bridge/rmgr/dspdrv.c |   27 ++++-----
 drivers/dsp/bridge/rmgr/mgr.c    |   23 +++----
 drivers/dsp/bridge/rmgr/nldr.c   |   32 ++++-------
 drivers/dsp/bridge/rmgr/node.c   |  123 ++++++++++++++++++--------------------
 drivers/dsp/bridge/rmgr/proc.c   |  100 +++++++++++++-----------------
 drivers/dsp/bridge/rmgr/strm.c   |   31 +++-------
 9 files changed, 217 insertions(+), 275 deletions(-)
drivers/dsp/bridge/rmgr/dbdcd.c +12 -19
index fed9f38..3d50952 100644
@@ -161,7 +161,6 @@ DSP_STATUS DCD_CreateManager(IN char *pszZlDllName,
 	status = COD_Create(&hCodMgr, pszZlDllName, NULL);
 
 	if (DSP_FAILED(status)) {
-		status = DSP_EFAIL;
 		GT_0trace(curTrace, GT_6CLASS,
 			 "DCD_CreateManager: COD_Create failed\n");
 		goto func_end;
@@ -442,8 +441,10 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 		 " 0x%x, objType 0x%x, pObjDef 0x%x\n", hDcdMgr, pObjUuid,
 		 objType, pObjDef);
 	szUuid = (char *)MEM_Calloc(MAXUUIDLEN, MEM_PAGED);
-	if (!szUuid)
-		return status = DSP_EMEMORY;
+	if (!szUuid) {
+		status = DSP_EMEMORY;
+		goto func_end;
+	}
 
 	if (!IsValidHandle(hDcdMgr)) {
 		status = DSP_EHANDLE;
@@ -759,13 +760,10 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,
 		sprintf(szObjType, "%d", DSP_DCDLIBRARYTYPE);
 		break;
 	default:
-		status = -1;
+		status = DSP_EINVALIDARG;
 		DBC_Assert(false);
 	}
-	if (status == -1) {
-		status = DSP_EFAIL;
-	} else {
-		status = DSP_SOK;
+	if (DSP_SUCCEEDED(status)) {
 		if ((strlen(szRegKey) + strlen(szObjType)) <
 		   REG_MAXREGPATHLENGTH) {
 			strncat(szRegKey, szObjType, strlen(szObjType) + 1);
@@ -943,23 +941,18 @@ DSP_STATUS DCD_RegisterObject(IN struct DSP_UUID *pUuid,
 		/* Add new reg value (UUID+objType) with COFF path info */
 		dwPathSize = strlen(pszPathName) + 1;
 		status = REG_SetValue(szRegKey, (u8 *)pszPathName, dwPathSize);
-		GT_2trace(curTrace, GT_6CLASS, "REG_SetValue "
-			"(u8 *)pszPathName=%s, dwPathSize=%d\n",
-			pszPathName, dwPathSize);
-
-		if (DSP_FAILED(status)) {
-			status = DSP_EFAIL;
+		GT_2trace(curTrace, GT_6CLASS, "REG_SetValue  "
+			  "(u8 *)pszPathName=%s, dwPathSize=%d\n",
+			  pszPathName, dwPathSize);
+		if (DSP_FAILED(status))
 			GT_0trace(curTrace, GT_6CLASS,
-				  "DCD_RegisterObject: REG_SetValue failed!\n");
-		}
+				"DCD_RegisterObject: REG_SetValue failed!\n");
 	} else {
 		/* Deregister an existing object */
 		status = REG_DeleteValue(szRegKey);
-		if (DSP_FAILED(status)) {
-			status = DSP_EFAIL;
+		if (DSP_FAILED(status))
 			GT_0trace(curTrace, GT_6CLASS, "DCD_UnregisterObject: "
 				"REG_DeleteValue failed!\n");
-		}
 	}
 
 
drivers/dsp/bridge/rmgr/disp.c +17 -19
index 6ea15b4..949c5e3 100644
@@ -160,23 +160,22 @@ DSP_STATUS DISP_Create(OUT struct DISP_OBJECT **phDispObject,
 		status = DSP_EFAIL;
 		goto func_cont;
 	}
-	if (DSP_SUCCEEDED(status)) {
-		pDisp->uCharSize = DSPWORDSIZE;
-		pDisp->uWordSize = DSPWORDSIZE;
-		pDisp->uDataMauSize = DSPWORDSIZE;
-		/* Open channels for communicating with the RMS */
-		chnlAttrs.uIOReqs = CHNLIOREQS;
-		chnlAttrs.hEvent = NULL;
-		ulChnlId = pDispAttrs->ulChnlOffset + CHNLTORMSOFFSET;
-		status = (*pIntfFxns->pfnChnlOpen)(&(pDisp->hChnlToDsp),
-			 pDisp->hChnlMgr, CHNL_MODETODSP, ulChnlId, &chnlAttrs);
-		if (DSP_FAILED(status)) {
-			GT_2trace(DISP_DebugMask, GT_6CLASS,
-				 "DISP_Create:  Channel to RMS "
-				 "open failed, chnl id = %d, status = 0x%x\n",
-				 ulChnlId, status);
-		}
-	}
+
+	pDisp->uCharSize = DSPWORDSIZE;
+	pDisp->uWordSize = DSPWORDSIZE;
+	pDisp->uDataMauSize = DSPWORDSIZE;
+	/* Open channels for communicating with the RMS */
+	chnlAttrs.uIOReqs = CHNLIOREQS;
+	chnlAttrs.hEvent = NULL;
+	ulChnlId = pDispAttrs->ulChnlOffset + CHNLTORMSOFFSET;
+	status = (*pIntfFxns->pfnChnlOpen)(&(pDisp->hChnlToDsp),
+		 pDisp->hChnlMgr, CHNL_MODETODSP, ulChnlId, &chnlAttrs);
+	if (DSP_FAILED(status))
+		GT_2trace(DISP_DebugMask, GT_6CLASS,
+			 "DISP_Create:  Channel to RMS "
+			 "open failed, chnl id = %d, status = 0x%x\n",
+			 ulChnlId, status);
+
 	if (DSP_SUCCEEDED(status)) {
 		ulChnlId = pDispAttrs->ulChnlOffset + CHNLFROMRMSOFFSET;
 		status = (*pIntfFxns->pfnChnlOpen)(&(pDisp->hChnlFromDsp),
@@ -819,7 +818,7 @@ static DSP_STATUS SendMessage(struct DISP_OBJECT *hDisp, u32 dwTimeout,
 		GT_1trace(DISP_DebugMask, GT_6CLASS,
 			 "SendMessage: Channel AddIOReq to"
 			 " RMS failed! Status = 0x%x\n", status);
-		goto func_cont;
+		goto func_end;
 	}
 	status = (*pIntfFxns->pfnChnlGetIOC) (hChnl, dwTimeout, &chnlIOC);
 	if (DSP_SUCCEEDED(status)) {
@@ -839,7 +838,6 @@ static DSP_STATUS SendMessage(struct DISP_OBJECT *hDisp, u32 dwTimeout,
 			 "SendMessage: Channel GetIOC to"
 			 " RMS failed! Status = 0x%x\n", status);
 	}
-func_cont:
 	/* Get the reply */
 	if (DSP_FAILED(status))
 		goto func_end;
drivers/dsp/bridge/rmgr/drv.c +46 -43

155 lines not on this page · raw message

drivers/dsp/bridge/rmgr/dspdrv.c +12 -15
index 183aba6..9920059 100644
@@ -56,7 +56,6 @@ u32 DSP_Init(OUT u32 *initStatus)
 	char devNode[MAXREGPATHLENGTH] = "TIOMAP1510";
 	DSP_STATUS status = DSP_EFAIL;
 	struct DRV_OBJECT *drvObject = NULL;
-	u32 index = 0;
 	u32 deviceNode;
 	u32 deviceNodeString;
 
@@ -64,11 +63,12 @@ u32 DSP_Init(OUT u32 *initStatus)
 
 	GT_0trace(curTrace, GT_ENTER, "Entering DSP_Init \r\n");
 
-	if (DSP_FAILED(WCD_Init())) {
+	if (!WCD_Init()) {
 		GT_0trace(curTrace, GT_7CLASS, "DSP_Init Failed \n");
 		goto func_cont;
 	}			/* End WCD_Exit */
-	if (DSP_FAILED(DRV_Create(&drvObject))) {
+	status = DRV_Create(&drvObject);
+	if (DSP_FAILED(status)) {
 		GT_0trace(curTrace, GT_7CLASS, "DSP_Init:DRV_Create Failed \n");
 		WCD_Exit();
 		goto func_cont;
@@ -76,29 +76,27 @@ u32 DSP_Init(OUT u32 *initStatus)
 	GT_0trace(curTrace, GT_5CLASS, "DSP_Init:DRV Created \r\n");
 
 	/* Request Resources */
-	if (DSP_SUCCEEDED(DRV_RequestResources((u32)&devNode,
-	   &deviceNodeString))) {
+	status = DRV_RequestResources((u32)&devNode, &deviceNodeString);
+	if (DSP_SUCCEEDED(status)) {
 		/* Attempt to Start the Device */
-		if (DSP_SUCCEEDED(DEV_StartDevice(
-		   (struct CFG_DEVNODE *)deviceNodeString))) {
+		status = DEV_StartDevice((struct CFG_DEVNODE *)
+							deviceNodeString);
+		if (DSP_SUCCEEDED(status)) {
 			/* Retreive the DevObject from the Registry */
-			GT_2trace(curTrace, GT_1CLASS,
-				 "DSP_Init Succeeded for Device1:"
-				 "%d: value: %x\n", index, deviceNodeString);
-			status = DSP_SOK;
+			GT_1trace(curTrace, GT_1CLASS,
+				 "DSP_Init Succeeded for Device1 value: %x\n",
+				 deviceNodeString);
 		} else {
 			GT_0trace(curTrace, GT_7CLASS,
 				 "DSP_Init:DEV_StartDevice Failed\n");
 			(void)DRV_ReleaseResources
 				((u32) deviceNodeString, drvObject);
-			status = DSP_EFAIL;
 		}
 	} else {
 		GT_0trace(curTrace, GT_7CLASS,
 			 "DSP_Init:DRV_RequestResources Failed \r\n");
 		status = DSP_EFAIL;
-	}	/* DRV_RequestResources */
-	index++;
+	}
 
 	/* Unwind whatever was loaded */
 	if (DSP_FAILED(status)) {
@@ -106,7 +104,6 @@ u32 DSP_Init(OUT u32 *initStatus)
 		 * unloading. Get the Driver Object iterate through and remove.
 		 * Reset the status to E_FAIL to avoid going through
 		 * WCD_InitComplete2. */
-		status = DSP_EFAIL;
 		for (deviceNode = DRV_GetFirstDevExtension(); deviceNode != 0;
 		    deviceNode = DRV_GetNextDevExtension(deviceNode)) {
 			(void)DEV_RemoveDevice
drivers/dsp/bridge/rmgr/mgr.c +9 -14
index d96716a..4562157 100644
@@ -74,16 +74,16 @@ DSP_STATUS MGR_Create(OUT struct MGR_OBJECT **phMgrObject,
 		 phMgrObject);
 	MEM_AllocObject(pMgrObject, struct MGR_OBJECT, SIGNATURE);
 	if (pMgrObject) {
-		if (DSP_SUCCEEDED(DCD_CreateManager(ZLDLLNAME,
-		   &pMgrObject->hDcdMgr))) {
+		status = DCD_CreateManager(ZLDLLNAME, &pMgrObject->hDcdMgr);
+		if (DSP_SUCCEEDED(status)) {
 			/* If succeeded store the handle in the MGR Object */
-			if (DSP_SUCCEEDED(CFG_SetObject((u32)pMgrObject,
-			   REG_MGR_OBJECT))) {
+			status = CFG_SetObject((u32)pMgrObject,
+							REG_MGR_OBJECT);
+			if (DSP_SUCCEEDED(status)) {
 				*phMgrObject = pMgrObject;
 				GT_0trace(MGR_DebugMask, GT_1CLASS,
 					 "MGR_Create:MGR Created\r\n");
 			} else {
-				status = DSP_EFAIL;
 				GT_0trace(MGR_DebugMask, GT_7CLASS,
 					 "MGR_Create:CFG_SetObject "
 					 "Failed\r\n");
@@ -92,7 +92,6 @@ DSP_STATUS MGR_Create(OUT struct MGR_OBJECT **phMgrObject,
 			}
 		} else {
 			/* failed to Create DCD Manager */
-			status = DSP_EFAIL;
 			GT_0trace(MGR_DebugMask, GT_7CLASS,
 				 "MGR_Create:DCD_ManagerCreate Failed\r\n");
 			MEM_FreeObject(pMgrObject);
@@ -151,7 +150,6 @@ DSP_STATUS MGR_EnumNodeInfo(u32 uNode, OUT struct DSP_NDBPROPS *pNDBProps,
 			   u32 uNDBPropsSize, OUT u32 *puNumNodes)
 {
 	DSP_STATUS status = DSP_SOK;
-	DSP_STATUS status1 = DSP_SOK;
 	struct DSP_UUID Uuid, uTempUuid;
 	u32 uTempIndex = 0;
 	u32 uNodeIndex = 0;
@@ -169,8 +167,8 @@ DSP_STATUS MGR_EnumNodeInfo(u32 uNode, OUT struct DSP_NDBPROPS *pNDBProps,
 		 uNDBPropsSize, puNumNodes);
 	*puNumNodes = 0;
 	/* Get The Manager Object from the Registry */
-	if (DSP_FAILED(CFG_GetObject((u32 *)&pMgrObject,
-	   REG_MGR_OBJECT))) {
+	status = CFG_GetObject((u32 *)&pMgrObject, REG_MGR_OBJECT);
+	if (DSP_FAILED(status)) {
 		GT_0trace(MGR_DebugMask, GT_7CLASS,
 			 "Manager_EnumNodeInfo:Failed To Get"
 			 " MGR Object from Registry\r\n");
@@ -196,26 +194,23 @@ DSP_STATUS MGR_EnumNodeInfo(u32 uNode, OUT struct DSP_NDBPROPS *pNDBProps,
 				 "Manager_EnumNodeInfo: uNode"
 				 " is Invalid \r\n");
 		} else {
-			status1 = DCD_GetObjectDef(pMgrObject->hDcdMgr,
+			status = DCD_GetObjectDef(pMgrObject->hDcdMgr,
 						(struct DSP_UUID *)&Uuid,
 						DSP_DCDNODETYPE, &GenObj);
-			if (DSP_SUCCEEDED(status1)) {
+			if (DSP_SUCCEEDED(status)) {
 				/* Get the Obj def */
 				*pNDBProps = GenObj.objData.nodeObj.ndbProps;
 				*puNumNodes = uNodeIndex;
-				status = DSP_SOK;
 			} else {
 				GT_0trace(MGR_DebugMask, GT_7CLASS,
 					 "Manager_EnumNodeInfo: "
 					 "Failed to Get Node Info \r\n");
-				status = DSP_EFAIL;
 			}
 		}
 	} else {
 		/* This could be changed during enum, EFAIL ... */
 		GT_0trace(MGR_DebugMask, GT_7CLASS, "Manager_EnumNodeInfo: "
 			 "Enumeration failure\r\n");
-		status = DSP_EFAIL;
 	}
 func_cont:
 	GT_4trace(MGR_DebugMask, GT_ENTER,
drivers/dsp/bridge/rmgr/nldr.c +11 -21
index 5f0d4e1..19861bd 100644
@@ -1018,7 +1018,7 @@ static DSP_STATUS AddOvlyInfo(void *handle, struct DBLL_SectInfo *sectInfo,
 
 	/* Determine which phase this section belongs to */
 	for (pch = pSectName + 1; *pch && *pch != seps; pch++)
-		;;
+		;
 
 	if (*pch) {
 		pch++;	/* Skip over the ':' */
@@ -1398,7 +1398,7 @@ static DSP_STATUS LoadLib(struct NLDR_NODEOBJECT *hNldrNode,
 	/*
 	 *  Recursively load dependent libraries.
 	 */
-	if (DSP_SUCCEEDED(status) && persistentDepLibs) {
+	if (DSP_SUCCEEDED(status)) {
 		for (i = 0; i < nLibs; i++) {
 			/* If root library is NOT persistent, and dep library
 			 * is, then record it.  If root library IS persistent,
@@ -1422,15 +1422,11 @@ static DSP_STATUS LoadLib(struct NLDR_NODEOBJECT *hNldrNode,
 				pDepLib = &root->pDepLibs[nLoaded];
 			}
 
-			if (depLibUUIDs) {
-				status = LoadLib(hNldrNode, pDepLib,
+			status = LoadLib(hNldrNode, pDepLib,
 						depLibUUIDs[i],
 						persistentDepLibs[i], libPath,
 						phase,
 						depth);
-			} else {
-				status = DSP_EMEMORY;
-			}
 
 			if (DSP_SUCCEEDED(status)) {
 				if ((status != DSP_SALREADYLOADED) &&
@@ -1555,10 +1551,6 @@ static DSP_STATUS LoadOvly(struct NLDR_NODEOBJECT *hNldrNode,
 		break;
 	}
 
-	DBC_Assert(pRefCount != NULL);
-	if (DSP_FAILED(status))
-		goto func_end;
-
 	if (pRefCount == NULL)
 		goto func_end;
 
@@ -1837,7 +1829,6 @@ static void UnloadOvly(struct NLDR_NODEOBJECT *hNldrNode, enum NLDR_PHASE phase)
 	u16 nOtherAlloc = 0;
 	u16 *pRefCount = NULL;
 	u16 *pOtherRef = NULL;
-	DSP_STATUS status = DSP_SOK;
 
 	/* Find the node in the table */
 	for (i = 0; i < hNldr->nOvlyNodes; i++) {
@@ -1878,17 +1869,16 @@ static void UnloadOvly(struct NLDR_NODEOBJECT *hNldrNode, enum NLDR_PHASE phase)
 		DBC_Assert(false);
 		break;
 	}
-	if (DSP_SUCCEEDED(status)) {
-		DBC_Assert(pRefCount && (*pRefCount > 0));
-		 if (pRefCount && (*pRefCount > 0)) {
-			*pRefCount -= 1;
-			if (pOtherRef) {
-				DBC_Assert(*pOtherRef > 0);
-				*pOtherRef -= 1;
-			}
+	DBC_Assert(pRefCount && (*pRefCount > 0));
+	if (pRefCount && (*pRefCount > 0)) {
+		*pRefCount -= 1;
+		if (pOtherRef) {
+			DBC_Assert(*pOtherRef > 0);
+			*pOtherRef -= 1;
 		}
 	}
-	if (pRefCount && (*pRefCount == 0)) {
+
+	if (pRefCount && *pRefCount == 0) {
 		/* 'Deallocate' memory */
 		FreeSects(hNldr, pPhaseSects, nAlloc);
 	}
drivers/dsp/bridge/rmgr/node.c +58 -65

288 lines not on this page · raw message

drivers/dsp/bridge/rmgr/proc.c +43 -57

237 lines not on this page · raw message

drivers/dsp/bridge/rmgr/strm.c +9 -22
index 9200aed..b0b4d32 100644
@@ -130,11 +130,13 @@ DSP_STATUS STRM_AllocateBuffer(struct STRM_OBJECT *hStrm, u32 uSize,
 		if (uSize == 0)
 			status = DSP_ESIZE;
 
-	}
-	if (DSP_FAILED(status)) {
+	} else {
 		status = DSP_EHANDLE;
-		goto func_end;
 	}
+
+	if (DSP_FAILED(status))
+		goto func_end;
+
 	for (i = 0; i < uNumBufs; i++) {
 		DBC_Assert(hStrm->hXlator != NULL);
 		(void)CMM_XlatorAllocBuf(hStrm->hXlator, &apBuffer[i], uSize);
@@ -191,20 +193,10 @@ DSP_STATUS STRM_Close(struct STRM_OBJECT *hStrm,
 		status = (*pIntfFxns->pfnChnlGetInfo) (hStrm->hChnl, &chnlInfo);
 		DBC_Assert(DSP_SUCCEEDED(status));
 
-		if (chnlInfo.cIOCs > 0 || chnlInfo.cIOReqs > 0) {
+		if (chnlInfo.cIOCs > 0 || chnlInfo.cIOReqs > 0)
 			status = DSP_EPENDING;
-		} else {
-
+		else
 			status = DeleteStrm(hStrm);
-
-			if (DSP_FAILED(status)) {
-				/* we already validated the handle. */
-				DBC_Assert(status != DSP_EHANDLE);
-
-				/* make sure we return a documented result */
-				status = DSP_EFAIL;
-			}
-		}
 	}
 #ifndef RES_CLEANUP_DISABLE
 	if (DSP_FAILED(status))
@@ -511,13 +503,8 @@ DSP_STATUS STRM_Issue(struct STRM_OBJECT *hStrm, IN u8 *pBuf, u32 ulBytes,
 				 (hStrm->hChnl, pBuf, ulBytes, ulBufSize,
 				 (u32) pTmpBuf, dwArg);
 		}
-		if (DSP_FAILED(status)) {
-			if (status == CHNL_E_NOIORPS)
-				status = DSP_ESTREAMFULL;
-			else
-				status = DSP_EFAIL;
-
-		}
+		if (status == CHNL_E_NOIORPS)
+			status = DSP_ESTREAMFULL;
 	}
 	return status;
 }
Signature · 1 line
1.6.2.4
author Applied
#4 lore raw
In reply to Omar Ramirez Luna
Quoted 25 lines

From: Ramirez Luna, Omar on Tuesday, January 19, 2010 12:15 PM

This set of patches fixes the overwritten or missing error codes returned from different bridge layers.

Fernando Guzman Lugo (3):
DSPBRIDGE: return right error codes wmd directory
DSPBRIDGE: return right error codes services directory
DSPBRIDGE: return right error codes rmgr directory

drivers/dsp/bridge/rmgr/dbdcd.c         |   31 ++--
drivers/dsp/bridge/rmgr/disp.c          |   36 ++--
drivers/dsp/bridge/rmgr/drv.c           |   89 +++++----
drivers/dsp/bridge/rmgr/dspdrv.c        |   27 ++--
drivers/dsp/bridge/rmgr/mgr.c           |   23 +--
drivers/dsp/bridge/rmgr/nldr.c          |   32 +--
drivers/dsp/bridge/rmgr/node.c          |  123 ++++++------
drivers/dsp/bridge/rmgr/proc.c          |  100 ++++------
drivers/dsp/bridge/rmgr/strm.c          |   31 +--
drivers/dsp/bridge/services/cfg.c       |    8 +-
drivers/dsp/bridge/services/clk.c       |    7 +-
drivers/dsp/bridge/services/reg.c       |   25 +--
drivers/dsp/bridge/services/sync.c      |    1 -
drivers/dsp/bridge/wmd/chnl_sm.c        |  230 +++++++++++------------
drivers/dsp/bridge/wmd/io_sm.c          |  322 ++++++++++++++-----------------
Quoted 8 lines
drivers/dsp/bridge/wmd/mmu_fault.c      |    4 +-
drivers/dsp/bridge/wmd/msg_sm.c         |   47 +++--
drivers/dsp/bridge/wmd/tiomap3430.c     |   28 +--
drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   10 +-
drivers/dsp/bridge/wmd/tiomap_io.c      |   10 +-
drivers/dsp/bridge/wmd/tiomap_sm.c      |    2 -
drivers/dsp/bridge/wmd/ue_deh.c         |   21 +--
22 files changed, 542 insertions(+), 665 deletions(-)

Pushed to dspbridge

- omar