summaryrefslogtreecommitdiff
path: root/drivers/staging/wilc1000/wilc_msgqueue.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-06-01 21:06:43 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-06-02 13:46:05 +0900
commit83383ea33c63a622619acf2b979037ee775500dd (patch)
treed21687c04b6a6403cfd89553ce0db6c5fef1cf4f /drivers/staging/wilc1000/wilc_msgqueue.c
parente14af67d8fb20128927b65d824b389698dd5c663 (diff)
staging: wilc1000: remove semaphore wrapper
The various semaphore functions all directly translate into sema_init(), down() and up(), so we can just remove the API. This is a mostly automated conversion using simple sed scripts, plus some manual changes to account for down() returning no error. As a positive side-effect, down() no longer hangs after receiving a signal, as the original code did by looping around down_interruptible. The semaphores still need to be turned into mutexes as a follow-up step. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wilc1000/wilc_msgqueue.c')
-rw-r--r--drivers/staging/wilc1000/wilc_msgqueue.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
index 1113092398d1..ebbba8b24de0 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -11,21 +11,12 @@
WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle,
tstrWILC_MsgQueueAttrs *pstrAttrs)
{
- tstrWILC_SemaphoreAttrs strSemAttrs;
- WILC_SemaphoreFillDefault(&strSemAttrs);
- strSemAttrs.u32InitCount = 0;
-
spin_lock_init(&pHandle->strCriticalSection);
- if ((WILC_SemaphoreCreate(&pHandle->hSem, &strSemAttrs) == WILC_SUCCESS)) {
-
- pHandle->pstrMessageList = NULL;
- pHandle->u32ReceiversCount = 0;
- pHandle->bExiting = WILC_FALSE;
-
- return WILC_SUCCESS;
- } else {
- return WILC_FAIL;
- }
+ sema_init(&pHandle->hSem, 0);
+ pHandle->pstrMessageList = NULL;
+ pHandle->u32ReceiversCount = 0;
+ pHandle->bExiting = WILC_FALSE;
+ return WILC_SUCCESS;
}
/*!
@@ -42,12 +33,10 @@ WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle,
/* Release any waiting receiver thread. */
while (pHandle->u32ReceiversCount > 0) {
- WILC_SemaphoreRelease(&(pHandle->hSem), WILC_NULL);
+ up(&(pHandle->hSem));
pHandle->u32ReceiversCount--;
}
- WILC_SemaphoreDestroy(&pHandle->hSem, WILC_NULL);
-
while (pHandle->pstrMessageList != NULL) {
Message *pstrMessge = pHandle->pstrMessageList->pstrNext;
WILC_FREE(pHandle->pstrMessageList);
@@ -104,7 +93,7 @@ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle,
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
- WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL);
+ up(&pHandle->hSem);
WILC_CATCH(s32RetStatus)
{
@@ -136,7 +125,6 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
Message *pstrMessage;
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
- tstrWILC_SemaphoreAttrs strSemAttrs;
unsigned long flags;
if ((pHandle == NULL) || (u32RecvBufferSize == 0)
|| (pvRecvBuffer == NULL) || (pu32ReceivedLength == NULL)) {
@@ -151,8 +139,8 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
pHandle->u32ReceiversCount++;
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
- WILC_SemaphoreFillDefault(&strSemAttrs);
- s32RetStatus = WILC_SemaphoreAcquire(&(pHandle->hSem), &strSemAttrs);
+ down(&(pHandle->hSem));
+
if (s32RetStatus == WILC_TIMEOUT) {
/* timed out, just exit without consumeing the message */
spin_lock_irqsave(&pHandle->strCriticalSection, flags);
@@ -176,7 +164,7 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
/* check buffer size */
if (u32RecvBufferSize < pstrMessage->u32Length) {
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
- WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL);
+ up(&pHandle->hSem);
WILC_ERRORREPORT(s32RetStatus, WILC_BUFFER_OVERFLOW);
}