staging: wilc1000: remove the macro WILC_ERRORREPORT
[deliverable/linux.git] / drivers / staging / wilc1000 / wilc_msgqueue.c
index 53b6f07a60c2846af73135cfbcb0bfe3014864ad..01fd94b35164f176853fc1bcf48ffab5e8d2ce1a 100644 (file)
@@ -59,11 +59,15 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
        Message *pstrMessage = NULL;
 
        if ((!pHandle) || (u32SendBufferSize == 0) || (!pvSendBuffer)) {
-               WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT);
+               PRINT_ER("pHandle or pvSendBuffer is null\n");
+               s32RetStatus = -EFAULT;
+               goto ERRORHANDLER;
        }
 
        if (pHandle->bExiting) {
-               WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
+               PRINT_ER("pHandle fail\n");
+               s32RetStatus = -EFAULT;
+               goto ERRORHANDLER;
        }
 
        spin_lock_irqsave(&pHandle->strCriticalSection, flags);
@@ -97,13 +101,11 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 
        up(&pHandle->hSem);
 
-       WILC_CATCH(s32RetStatus)
-       {
-               /* error occured, free any allocations */
-               if (pstrMessage) {
-                       kfree(pstrMessage->pvBuffer);
-                       kfree(pstrMessage);
-               }
+ERRORHANDLER:
+       /* error occured, free any allocations */
+       if (pstrMessage) {
+               kfree(pstrMessage->pvBuffer);
+               kfree(pstrMessage);
        }
 
        return s32RetStatus;
@@ -125,11 +127,13 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
 
        if ((!pHandle) || (u32RecvBufferSize == 0)
            || (!pvRecvBuffer) || (!pu32ReceivedLength)) {
-               WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT);
+               PRINT_ER("pHandle or pvRecvBuffer is null\n");
+               return -EINVAL;
        }
 
        if (pHandle->bExiting) {
-               WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
+               PRINT_ER("pHandle fail\n");
+               return -EFAULT;
        }
 
        spin_lock_irqsave(&pHandle->strCriticalSection, flags);
@@ -138,52 +142,44 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
 
        down(&pHandle->hSem);
 
-       if (s32RetStatus == WILC_TIMEOUT) {
-               /* timed out, just exit without consumeing the message */
-               spin_lock_irqsave(&pHandle->strCriticalSection, flags);
-               pHandle->u32ReceiversCount--;
-               spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
-       } else {
-               /* other non-timeout scenarios */
-               if (s32RetStatus) {
-                       PRINT_ER("Non-timeout\n");
-                       return s32RetStatus;
-               }
-
-               if (pHandle->bExiting) {
-                       WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
-               }
-
-               spin_lock_irqsave(&pHandle->strCriticalSection, flags);
-
-               pstrMessage = pHandle->pstrMessageList;
-               if (!pstrMessage) {
-                       spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
-                       WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
-               }
-               /* check buffer size */
-               if (u32RecvBufferSize < pstrMessage->u32Length) {
-                       spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
-                       up(&pHandle->hSem);
-                       WILC_ERRORREPORT(s32RetStatus, WILC_BUFFER_OVERFLOW);
-               }
-
-               /* consume the message */
-               pHandle->u32ReceiversCount--;
-               memcpy(pvRecvBuffer, pstrMessage->pvBuffer, pstrMessage->u32Length);
-               *pu32ReceivedLength = pstrMessage->u32Length;
+       /* other non-timeout scenarios */
+       if (s32RetStatus) {
+               PRINT_ER("Non-timeout\n");
+               return s32RetStatus;
+       }
 
-               pHandle->pstrMessageList = pstrMessage->pstrNext;
+       if (pHandle->bExiting) {
+               PRINT_ER("pHandle fail\n");
+               return -EFAULT;
+       }
 
-               kfree(pstrMessage->pvBuffer);
-               kfree(pstrMessage);
+       spin_lock_irqsave(&pHandle->strCriticalSection, flags);
 
+       pstrMessage = pHandle->pstrMessageList;
+       if (!pstrMessage) {
                spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+               PRINT_ER("pstrMessage is null\n");
+               return -EFAULT;
        }
-
-       WILC_CATCH(s32RetStatus)
-       {
+       /* check buffer size */
+       if (u32RecvBufferSize < pstrMessage->u32Length) {
+               spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+               up(&pHandle->hSem);
+               PRINT_ER("u32RecvBufferSize overflow\n");
+               return -EOVERFLOW;
        }
 
+       /* consume the message */
+       pHandle->u32ReceiversCount--;
+       memcpy(pvRecvBuffer, pstrMessage->pvBuffer, pstrMessage->u32Length);
+       *pu32ReceivedLength = pstrMessage->u32Length;
+
+       pHandle->pstrMessageList = pstrMessage->pstrNext;
+
+       kfree(pstrMessage->pvBuffer);
+       kfree(pstrMessage);
+
+       spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+
        return s32RetStatus;
 }
This page took 0.030248 seconds and 5 git commands to generate.