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@xxxxxxxx> --- drivers/staging/wilc1000/coreconfigurator.c | 29 +--- drivers/staging/wilc1000/fifo_buffer.c | 108 +++++++------- drivers/staging/wilc1000/fifo_buffer.h | 2 +- drivers/staging/wilc1000/host_interface.c | 171 +++++++++------------- drivers/staging/wilc1000/host_interface.h | 16 +- drivers/staging/wilc1000/wilc_msgqueue.c | 32 ++-- drivers/staging/wilc1000/wilc_oswrapper.h | 3 - drivers/staging/wilc1000/wilc_platform.h | 4 +- drivers/staging/wilc1000/wilc_semaphore.c | 56 ------- drivers/staging/wilc1000/wilc_semaphore.h | 99 ------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 35 ++--- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 +- 12 files changed, 160 insertions(+), 399 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_semaphore.c delete mode 100644 drivers/staging/wilc1000/wilc_semaphore.h diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index d5a076ed2426..bf444825711f 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -164,8 +164,8 @@ extern void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32 /*****************************************************************************/ /* Global Variables */ /*****************************************************************************/ -static WILC_SemaphoreHandle SemHandleSendPkt; -static WILC_SemaphoreHandle SemHandlePktResp; +static struct semaphore SemHandleSendPkt; +static struct semaphore SemHandlePktResp; static WILC_Sint8 *gps8ConfigPacket; @@ -672,18 +672,10 @@ INLINE WILC_Uint16 get_asoc_id(WILC_Uint8 *data) WILC_Sint32 CoreConfiguratorInit(void) { WILC_Sint32 s32Error = WILC_SUCCESS; - tstrWILC_SemaphoreAttrs strSemSendPktAttrs; - tstrWILC_SemaphoreAttrs strSemPktRespAttrs; - PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit() \n"); - WILC_SemaphoreFillDefault(&strSemSendPktAttrs); - strSemSendPktAttrs.u32InitCount = 1; - WILC_SemaphoreCreate(&SemHandleSendPkt, &strSemSendPktAttrs); - - WILC_SemaphoreFillDefault(&strSemPktRespAttrs); - strSemPktRespAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&SemHandlePktResp, &strSemPktRespAttrs); + sema_init(&SemHandleSendPkt, 1); + sema_init(&SemHandlePktResp, 0); gps8ConfigPacket = (WILC_Sint8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE); if (gps8ConfigPacket == NULL) { @@ -1931,7 +1923,7 @@ WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBu if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { - WILC_SemaphoreAcquire(&SemHandlePktResp, WILC_NULL); + down(&SemHandlePktResp); *ps32BytesRead = gstrConfigPktInfo.s32BytesRead; } @@ -1964,7 +1956,7 @@ WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, WILC_Sint32 s32ConfigPacketLen = 0; WILC_Sint32 s32RcvdRespLen = 0; - WILC_SemaphoreAcquire(&SemHandleSendPkt, WILC_NULL); + down(&SemHandleSendPkt); /*set the packet mode*/ g_oper_mode = u8Mode; @@ -2019,7 +2011,7 @@ WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, End_ConfigPkt: - WILC_SemaphoreRelease(&SemHandleSendPkt, WILC_NULL); + up(&SemHandleSendPkt); return s32Error; } @@ -2038,7 +2030,7 @@ WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLe PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size \n"); } - WILC_SemaphoreRelease(&SemHandlePktResp, WILC_NULL); + up(&SemHandlePktResp); } return s32Error; @@ -2107,11 +2099,6 @@ WILC_Sint32 CoreConfiguratorDeInit(void) PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit() \n"); - - WILC_SemaphoreDestroy(&SemHandleSendPkt, WILC_NULL); - WILC_SemaphoreDestroy(&SemHandlePktResp, WILC_NULL); - - if (gps8ConfigPacket != NULL) { WILC_FREE(gps8ConfigPacket); diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c index 733d81f2eeca..e23d11130728 100644 --- a/drivers/staging/wilc1000/fifo_buffer.c +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -13,13 +13,10 @@ WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength) WILC_memset (pstrFifoHandler, 0, sizeof (tstrFifoHandler)); pstrFifoHandler->pu8Buffer = WILC_MALLOC (u32BufferLength); if (pstrFifoHandler->pu8Buffer) { - tstrWILC_SemaphoreAttrs strSemBufferAttrs; pstrFifoHandler->u32BufferLength = u32BufferLength; WILC_memset (pstrFifoHandler->pu8Buffer, 0, u32BufferLength); /* create semaphore */ - WILC_SemaphoreFillDefault (&strSemBufferAttrs); - strSemBufferAttrs.u32InitCount = 1; - WILC_SemaphoreCreate(&pstrFifoHandler->SemBuffer, &strSemBufferAttrs); + sema_init(&pstrFifoHandler->SemBuffer, 1); *hBuffer = pstrFifoHandler; } else { *hBuffer = NULL; @@ -41,8 +38,6 @@ WILC_Uint32 FIFO_DeInit(tHANDLE hFifo) u32Error = 1; } - WILC_SemaphoreDestroy (&pstrFifoHandler->SemBuffer, WILC_NULL); - WILC_FREE (pstrFifoHandler); } else { u32Error = 1; @@ -56,34 +51,32 @@ WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32 tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; if (pstrFifoHandler && pu32BytesRead) { if (pstrFifoHandler->u32TotalBytes) { - if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) { - if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) { - *pu32BytesRead = pstrFifoHandler->u32TotalBytes; - } else { - *pu32BytesRead = u32BytesToRead; - } - if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) { - WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, - *pu32BytesRead); - /* update read offset and total bytes */ - pstrFifoHandler->u32ReadOffset += u32BytesToRead; - pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + down(&pstrFifoHandler->SemBuffer); - } else { - WILC_Uint32 u32FirstPart = - pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset; - WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, - u32FirstPart); - WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer, - u32BytesToRead - u32FirstPart); - /* update read offset and total bytes */ - pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart; - pstrFifoHandler->u32TotalBytes -= u32BytesToRead; - } - WILC_SemaphoreRelease (&pstrFifoHandler->SemBuffer, WILC_NULL); + if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) { + *pu32BytesRead = pstrFifoHandler->u32TotalBytes; } else { - u32Error = 1; + *pu32BytesRead = u32BytesToRead; } + if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) { + WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, + *pu32BytesRead); + /* update read offset and total bytes */ + pstrFifoHandler->u32ReadOffset += u32BytesToRead; + pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + + } else { + WILC_Uint32 u32FirstPart = + pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset; + WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, + u32FirstPart); + WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer, + u32BytesToRead - u32FirstPart); + /* update read offset and total bytes */ + pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart; + pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + } + up(&pstrFifoHandler->SemBuffer); } else { u32Error = 1; } @@ -101,34 +94,33 @@ WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u3 if (u32BytesToWrite < pstrFifoHandler->u32BufferLength) { if ((pstrFifoHandler->u32TotalBytes + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength || bForceOverWrite) { - if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) { - if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) { - WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, - u32BytesToWrite); - /* update read offset and total bytes */ - pstrFifoHandler->u32WriteOffset += u32BytesToWrite; - pstrFifoHandler->u32TotalBytes += u32BytesToWrite; + down(&pstrFifoHandler->SemBuffer); + if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) { + WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, + u32BytesToWrite); + /* update read offset and total bytes */ + pstrFifoHandler->u32WriteOffset += u32BytesToWrite; + pstrFifoHandler->u32TotalBytes += u32BytesToWrite; - } else { - WILC_Uint32 u32FirstPart = - pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset; - WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, - u32FirstPart); - WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart, - u32BytesToWrite - u32FirstPart); - /* update read offset and total bytes */ - pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart; - pstrFifoHandler->u32TotalBytes += u32BytesToWrite; - } - /* if data overwriten */ - if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) { - /* adjust read offset to the oldest data available */ - pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset; - /* data availabe is the buffer length */ - pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength; - } - WILC_SemaphoreRelease(&pstrFifoHandler->SemBuffer, WILC_NULL); + } else { + WILC_Uint32 u32FirstPart = + pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset; + WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, + u32FirstPart); + WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart, + u32BytesToWrite - u32FirstPart); + /* update read offset and total bytes */ + pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart; + pstrFifoHandler->u32TotalBytes += u32BytesToWrite; } + /* if data overwriten */ + if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) { + /* adjust read offset to the oldest data available */ + pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset; + /* data availabe is the buffer length */ + pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength; + } + up(&pstrFifoHandler->SemBuffer); } else { u32Error = 1; } @@ -139,4 +131,4 @@ WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u3 u32Error = 1; } return u32Error; -} \ No newline at end of file +} diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h index 0700e7929c00..c7e140be8fab 100644 --- a/drivers/staging/wilc1000/fifo_buffer.h +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -10,7 +10,7 @@ typedef struct { WILC_Uint32 u32WriteOffset; WILC_Uint32 u32ReadOffset; WILC_Uint32 u32TotalBytes; - WILC_SemaphoreHandle SemBuffer; + struct semaphore SemBuffer; } tstrFifoHandler; diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 7c764a2ba573..8f7adc760500 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -545,11 +545,11 @@ WILC_Bool g_obtainingIP = WILC_FALSE; WILC_Uint8 P2P_LISTEN_STATE; static struct task_struct *HostIFthreadHandler; static WILC_MsgQueueHandle gMsgQHostIF; -static WILC_SemaphoreHandle hSemHostIFthrdEnd; +static struct semaphore hSemHostIFthrdEnd; -WILC_SemaphoreHandle hSemDeinitDrvHandle; -static WILC_SemaphoreHandle hWaitResponse; -WILC_SemaphoreHandle hSemHostIntDeinit; +struct semaphore hSemDeinitDrvHandle; +static struct semaphore hWaitResponse; +struct semaphore hSemHostIntDeinit; WILC_TimerHandle g_hPeriodicRSSI; @@ -663,7 +663,7 @@ static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSe if ((pstrHostIfSetDrvHandler->u32Address) == (WILC_Uint32)NULL) { - WILC_SemaphoreRelease(&hSemDeinitDrvHandle, WILC_NULL); + up(&hSemDeinitDrvHandle); } @@ -709,7 +709,7 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat if ((pstrHostIfSetOperationMode->u32Mode) == (WILC_Uint32)NULL) { - WILC_SemaphoreRelease(&hSemDeinitDrvHandle, WILC_NULL); + up(&hSemDeinitDrvHandle); } @@ -906,7 +906,7 @@ static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddres { } - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; } @@ -929,7 +929,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); PRINT_D(HOSTINF_DBG, "Setting CFG params\n"); @@ -1214,7 +1214,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str WILC_CATCH(s32Error) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); return s32Error; } @@ -1232,7 +1232,7 @@ static WILC_Sint32 Handle_wait_msg_q_empty(void) { WILC_Sint32 s32Error = WILC_SUCCESS; g_wilc_initialized = 0; - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; } @@ -2818,7 +2818,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); break; case WPARxGtk: @@ -2867,7 +2867,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } @@ -2914,7 +2914,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } _WPARxGtk_end_case_: @@ -2970,7 +2970,7 @@ _WPARxGtk_end_case_: WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } #endif @@ -3011,7 +3011,7 @@ _WPARxGtk_end_case_: WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } @@ -3176,7 +3176,7 @@ static void Handle_Disconnect(void *drvHandler) } /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestDisconnectBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestDisconnectBlock)); /* ///////////////////////// */ } @@ -3264,7 +3264,7 @@ static WILC_Sint32 Handle_GetChnl(void *drvHandler) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetCHNL), WILC_NULL); + up(&(pstrWFIDrv->hSemGetCHNL)); return s32Error; @@ -3306,7 +3306,7 @@ static void Handle_GetRssi(void *drvHandler) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetRSSI), WILC_NULL); + up(&(pstrWFIDrv->hSemGetRSSI)); } @@ -3337,7 +3337,7 @@ static void Handle_GetLinkspeed(void *drvHandler) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetLINKSPEED), WILC_NULL); + up(&(pstrWFIDrv->hSemGetLINKSPEED)); } @@ -3383,7 +3383,7 @@ WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistic PRINT_ER("Failed to send scan paramters config packet\n"); /* WILC_ERRORREPORT(s32Error, s32Error); */ } - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return 0; } @@ -3449,7 +3449,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime); - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemInactiveTime), WILC_NULL); + up(&(pstrWFIDrv->hSemInactiveTime)); WILC_CATCH(s32Error) { @@ -3730,7 +3730,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt } WILC_FREE_IF_TRUE(strWID.ps8WidVal); - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); } @@ -4301,7 +4301,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo WILC_FREE(strWID.ps8WidVal); /*BugID_5222*/ - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; @@ -4355,7 +4355,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi WILC_FREE(strWID.ps8WidVal); /*BugID_5222*/ - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; @@ -4590,7 +4590,7 @@ static int hostIFthread(void *pvArg) } PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n"); - WILC_SemaphoreRelease(&hSemHostIFthrdEnd, WILC_NULL); + up(&hSemHostIFthrdEnd); return 0; } @@ -4692,7 +4692,7 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyI s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Error in sending message queue : Request to remove WEP key \n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4741,7 +4741,7 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Error in sending message queue : Default key index\n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4809,7 +4809,7 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_U s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Error in sending message queue :WEP Key\n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4886,7 +4886,7 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui if (s32Error) PRINT_ER("Error in sending message queue :WEP Key\n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4989,7 +4989,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC PRINT_ER("Error in sending message queue: PTK Key\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); /* WILC_Sleep(100); */ /* /////// */ @@ -5093,7 +5093,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxGtk, if (s32Error) PRINT_ER("Error in sending message queue: RX GTK\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); /* WILC_Sleep(100); */ /* /////// */ @@ -5151,7 +5151,7 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, PRINT_ER("Error in sending message queue: TX GTK\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&hSemTestKeyBlock, NULL); + down(&hSemTestKeyBlock); WILC_Sleep(100); /* /////// */ @@ -5322,7 +5322,7 @@ WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ma return WILC_FAIL; } - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } @@ -5703,7 +5703,7 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Reason if (s32Error) PRINT_ER("Failed to send message queue: disconnect\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestDisconnectBlock), NULL); + down(&(pstrWFIDrv->hSemTestDisconnectBlock)); /* /////// */ WILC_CATCH(s32Error) @@ -5922,7 +5922,7 @@ WILC_Sint32 host_int_wait_msg_queue_idle(void) } /* wait untill MSG Q is empty */ - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; @@ -6018,7 +6018,7 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Failed to send get host channel param's message queue "); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetCHNL), NULL); + down(&(pstrWFIDrv->hSemGetCHNL)); /* gu8Chnl = 11; */ *pu8ChNo = gu8Chnl; @@ -6115,7 +6115,7 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *ma if (s32Error) PRINT_ER("Failed to send get host channel param's message queue "); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemInactiveTime), NULL); + down(&(pstrWFIDrv->hSemInactiveTime)); *pu32InactiveTime = gu32InactiveTime; @@ -6205,7 +6205,7 @@ WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi) return WILC_FAIL; } - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetRSSI), NULL); + down(&(pstrWFIDrv->hSemGetRSSI)); if (ps8Rssi == NULL) { @@ -6242,7 +6242,7 @@ WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8ln return WILC_FAIL; } - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetLINKSPEED), NULL); + down(&(pstrWFIDrv->hSemGetLINKSPEED)); if (ps8lnkspd == NULL) { @@ -6276,7 +6276,7 @@ WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *p return WILC_FAIL; } - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } @@ -6418,7 +6418,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); if (pstrWFIDrv == WILC_NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); @@ -6503,7 +6503,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint break; } - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); WILC_CATCH(s32Error) { @@ -6598,8 +6598,6 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv; - tstrWILC_SemaphoreAttrs strSemaphoreAttrs; - /*if(u32Intialized == 1) * { @@ -6611,11 +6609,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) gbScanWhileConnected = WILC_FALSE; - WILC_SemaphoreFillDefault(&strSemaphoreAttrs); - - - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&hWaitResponse, &strSemaphoreAttrs); + sema_init(&hWaitResponse, 0); @@ -6640,29 +6634,18 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) PRINT_D(HOSTINF_DBG, "Global handle pointer value=%x\n", (WILC_Uint32)pstrWFIDrv); /* /////////////////////////////////////// */ if (clients_count == 0) { - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&hSemHostIFthrdEnd, &strSemaphoreAttrs); - - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&hSemDeinitDrvHandle, &strSemaphoreAttrs); - + sema_init(&hSemHostIFthrdEnd, 0); + sema_init(&hSemDeinitDrvHandle, 0); /*BugID_5348*/ - strSemaphoreAttrs.u32InitCount = 1; - WILC_SemaphoreCreate(&hSemHostIntDeinit, &strSemaphoreAttrs); - } - - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemTestKeyBlock), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemTestDisconnectBlock), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetRSSI), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetLINKSPEED), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetCHNL), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemInactiveTime), &strSemaphoreAttrs); + sema_init(&hSemHostIntDeinit, 1); + } + + sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0); + sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0); + sema_init(&(pstrWFIDrv->hSemGetRSSI), 0); + sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0); + sema_init(&(pstrWFIDrv->hSemGetCHNL), 0); + sema_init(&(pstrWFIDrv->hSemInactiveTime), 0); /* /////////////////////////////////////// */ @@ -6718,8 +6701,8 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) } #endif - WILC_SemaphoreCreate(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); @@ -6752,7 +6735,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) pstrWFIDrv->strCfgValues.curr_tx_rate); - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); /*TODO Code to setup simulation to be removed later*/ /*Intialize configurator module*/ @@ -6781,7 +6764,7 @@ _fail_timer_3: WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); #endif _fail_timer_2: - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), WILC_NULL); _fail_timer_1: WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL); @@ -6825,7 +6808,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) return 0; } - WILC_SemaphoreAcquire(&hSemHostIntDeinit, NULL); + down(&hSemHostIntDeinit); terminated_handle = pstrWFIDrv; PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count); @@ -6855,7 +6838,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) #endif host_int_set_wfi_drv_handler((WILC_Uint32)WILC_NULL); - WILC_SemaphoreAcquire(&hSemDeinitDrvHandle, NULL); + down(&hSemDeinitDrvHandle); /*Calling the CFG80211 scan done function with the abort flag set to true*/ @@ -6894,29 +6877,15 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error); } - WILC_SemaphoreAcquire(&hSemHostIFthrdEnd, NULL); + down(&hSemHostIFthrdEnd); WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); msgQ_created = 0; - - - WILC_SemaphoreDestroy(&hSemHostIFthrdEnd, NULL); - WILC_SemaphoreDestroy(&hSemDeinitDrvHandle, NULL); - } - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemTestKeyBlock), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemTestDisconnectBlock), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetRSSI), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetLINKSPEED), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetCHNL), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemInactiveTime), NULL); - WILC_SemaphoreDestroy(&hWaitResponse, NULL); - - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); /*Setting the gloabl driver handler with NULL*/ u32Intialized = 0; @@ -6929,7 +6898,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) clients_count--; /* Decrease number of created entities */ terminated_handle = WILC_NULL; - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return s32Error; } @@ -7003,7 +6972,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; /*BugID_5348*/ - WILC_SemaphoreAcquire(&hSemHostIntDeinit, NULL); + down(&hSemHostIntDeinit); drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -7013,7 +6982,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n"); /*BugID_5348*/ - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return; } @@ -7021,7 +6990,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) /* received mac status is not needed when there is no current Connect Request */ PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n"); /*BugID_5348*/ - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return; } @@ -7045,7 +7014,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) } /*BugID_5348*/ - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return; } @@ -7517,7 +7486,7 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8Mac { } - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; @@ -7945,7 +7914,7 @@ WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char } /*BugID_5222*/ - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } @@ -7980,7 +7949,7 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI } /*BugID_5222*/ - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index f2a348506a8b..9c06db12b7ea 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -422,14 +422,14 @@ typedef struct { WILC_Uint8 au8AssociatedBSSID[ETH_ALEN]; tstrCfgParamVal strCfgValues; /* semaphores */ - WILC_SemaphoreHandle gtOsCfgValuesSem; - WILC_SemaphoreHandle hSemTestKeyBlock; - - WILC_SemaphoreHandle hSemTestDisconnectBlock; - WILC_SemaphoreHandle hSemGetRSSI; - WILC_SemaphoreHandle hSemGetLINKSPEED; - WILC_SemaphoreHandle hSemGetCHNL; - WILC_SemaphoreHandle hSemInactiveTime; + struct semaphore gtOsCfgValuesSem; + struct semaphore hSemTestKeyBlock; + + struct semaphore hSemTestDisconnectBlock; + struct semaphore hSemGetRSSI; + struct semaphore hSemGetLINKSPEED; + struct semaphore hSemGetCHNL; + struct semaphore hSemInactiveTime; /* timer handlers */ WILC_TimerHandle hScanTimer; WILC_TimerHandle hConnectTimer; 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); } diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 1999970635aa..7375ec44cc42 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -54,9 +54,6 @@ typedef WILC_Uint16 WILC_WideChar; /* Error reporting and handling support */ #include "wilc_errorsupport.h" -/* Semaphore support */ -#include "wilc_semaphore.h" - /* Sleep support */ #include "wilc_sleep.h" diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 2e0f41735df0..ae42bbcbd5eb 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -16,8 +16,6 @@ * OS specific types *******************************************************************/ -typedef struct semaphore WILC_SemaphoreHandle; - typedef struct timer_list WILC_TimerHandle; @@ -30,7 +28,7 @@ typedef struct __Message_struct { } Message; typedef struct __MessageQueue_struct { - WILC_SemaphoreHandle hSem; + struct semaphore hSem; spinlock_t strCriticalSection; WILC_Bool bExiting; WILC_Uint32 u32ReceiversCount; diff --git a/drivers/staging/wilc1000/wilc_semaphore.c b/drivers/staging/wilc1000/wilc_semaphore.c deleted file mode 100644 index f09a88ca6ae4..000000000000 --- a/drivers/staging/wilc1000/wilc_semaphore.c +++ /dev/null @@ -1,56 +0,0 @@ - -#include "wilc_oswrapper.h" - -WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - tstrWILC_SemaphoreAttrs strDefaultAttrs; - if (pstrAttrs == WILC_NULL) { - WILC_SemaphoreFillDefault(&strDefaultAttrs); - pstrAttrs = &strDefaultAttrs; - } - - sema_init(pHandle, pstrAttrs->u32InitCount); - return WILC_SUCCESS; - -} - - -WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - /* nothing to be done ! */ - - return WILC_SUCCESS; - -} - - -WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - WILC_ErrNo s32RetStatus = WILC_SUCCESS; - - while (down_interruptible(pHandle)) - ; - - if (s32RetStatus == 0) { - return WILC_SUCCESS; - } else if (s32RetStatus == -ETIME) { - return WILC_TIMEOUT; - } else { - return WILC_FAIL; - } - - return WILC_SUCCESS; - -} - -WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - - up(pHandle); - return WILC_SUCCESS; - -} diff --git a/drivers/staging/wilc1000/wilc_semaphore.h b/drivers/staging/wilc1000/wilc_semaphore.h deleted file mode 100644 index 3c0ecc326fb3..000000000000 --- a/drivers/staging/wilc1000/wilc_semaphore.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __WILC_SEMAPHORE_H__ -#define __WILC_SEMAPHORE_H__ - -/*! - * @file wilc_semaphore.h - * @brief Semaphore OS Wrapper functionality - * @author syounan - * @sa wilc_oswrapper.h top level OS wrapper file - * @date 10 Aug 2010 - * @version 1.0 - */ - -/*! - * @struct WILC_SemaphoreAttrs - * @brief Semaphore API options - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -typedef struct { - /*!< - * Initial count when the semaphore is created. default is 1 - */ - WILC_Uint32 u32InitCount; - -} tstrWILC_SemaphoreAttrs; - - -/*! - * @brief Fills the WILC_SemaphoreAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -static inline void WILC_SemaphoreFillDefault(tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - pstrAttrs->u32InitCount = 1; -} -/*! - * @brief Creates a new Semaphore object - * @param[out] pHandle handle to the newly created semaphore - * @param[in] pstrAttrs Optional attributes, NULL for defaults - * pstrAttrs->u32InitCount controls the initial count - * @return Error code indicating success/failure - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - -/*! - * @brief Destroyes an existing Semaphore, releasing any resources - * @param[in] pHandle handle to the semaphore object - * @param[in] pstrAttrs Optional attributes, NULL for defaults - * @return Error code indicating success/failure - * @sa WILC_SemaphoreAttrs - * @todo need to define behaviour if the semaphore delayed while it is pending - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - -/*! - * @brief Acquire the Semaphore object - * @details This function will block until it can Acquire the given - * semaphore, if the feature WILC_OS_FEATURE_SEMAPHORE_TIMEOUT is - * eanbled a timeout value can be passed in pstrAttrs - * @param[in] pHandle handle to the semaphore object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating success/failure - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - -/*! - * @brief Release the Semaphore object - * @param[in] pHandle handle to the semaphore object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - - -#endif diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index c1d511825147..d8ca75cf73f6 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -462,7 +462,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo PRINT_D(CFG80211_DBG, "No networks found \n"); } - WILC_SemaphoreAcquire(&(priv->hSemScanReq), NULL); + down(&(priv->hSemScanReq)); if (priv->pstrScanReq != WILC_NULL) { cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); @@ -470,12 +470,12 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo priv->bCfgScanning = WILC_FALSE; priv->pstrScanReq = WILC_NULL; } - WILC_SemaphoreRelease(&(priv->hSemScanReq), NULL); + up(&(priv->hSemScanReq)); } /*Aborting any scan operation during mac close*/ else if (enuScanEvent == SCAN_EVENT_ABORTED) { - WILC_SemaphoreAcquire(&(priv->hSemScanReq), NULL); + down(&(priv->hSemScanReq)); PRINT_D(CFG80211_DBG, "Scan Aborted \n"); if (priv->pstrScanReq != WILC_NULL) { @@ -487,7 +487,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo priv->bCfgScanning = WILC_FALSE; priv->pstrScanReq = WILC_NULL; } - WILC_SemaphoreRelease(&(priv->hSemScanReq), NULL); + up(&(priv->hSemScanReq)); } } @@ -2839,13 +2839,13 @@ static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev, STATION_INFO_RX_BYTES | STATION_INFO_RX_PACKETS | STATION_INFO_SIGNAL | STATION_INFO_INACTIVE_TIME; - WILC_SemaphoreAcquire(&SemHandleUpdateStats, NULL); + down(&SemHandleUpdateStats); sinfo->inactive_time = priv->netstats.rx_time > priv->netstats.tx_time ? jiffies_to_msecs(jiffies - priv->netstats.tx_time) : jiffies_to_msecs(jiffies - priv->netstats.rx_time); sinfo->rx_bytes = priv->netstats.rx_bytes; sinfo->tx_bytes = priv->netstats.tx_bytes; sinfo->rx_packets = priv->netstats.rx_packets; sinfo->tx_packets = priv->netstats.tx_packets; - WILC_SemaphoreRelease(&SemHandleUpdateStats, NULL); + up(&SemHandleUpdateStats); #endif return 0; @@ -3767,7 +3767,7 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) struct WILC_WFI_priv *priv; priv = wiphy_priv(wiphy); - /* WILC_SemaphoreAcquire(&SemHandleUpdateStats,NULL); */ + /* down(&SemHandleUpdateStats); */ #if 1 switch (changed) { @@ -3792,7 +3792,7 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) default: break; } - /* WILC_SemaphoreRelease(&SemHandleUpdateStats,NULL); */ + /* down(&SemHandleUpdateStats); */ #endif return 0; } @@ -3898,7 +3898,7 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) /*Return hardware description structure (wiphy)'s priv*/ priv = wdev_priv(wdev); - WILC_SemaphoreCreate(&(priv->SemHandleUpdateStats), NULL); + sema_init(&(priv->SemHandleUpdateStats), 1); /*Link the wiphy with wireless structure*/ priv->wdev = wdev; @@ -3991,8 +3991,6 @@ int WILC_WFI_InitHostInt(struct net_device *net) struct WILC_WFI_priv *priv; - tstrWILC_SemaphoreAttrs strSemaphoreAttrs; - PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); priv = wdev_priv(net->ieee80211_ptr); if (op_ifcs == 0) { @@ -4007,17 +4005,11 @@ int WILC_WFI_InitHostInt(struct net_device *net) return s32Error; } - WILC_SemaphoreFillDefault(&strSemaphoreAttrs); - - /* /////////////////////////////////////// */ - /* strSemaphoreAttrs.u32InitCount = 0; */ - - priv->gbAutoRateAdjusted = WILC_FALSE; priv->bInP2PlistenState = WILC_FALSE; - WILC_SemaphoreCreate(&(priv->hSemScanReq), &strSemaphoreAttrs); + sema_init(&(priv->hSemScanReq), 1); s32Error = host_int_init(&priv->hWILCWFIDrv); /* s32Error = host_int_init(&priv->hWILCWFIDrv_2); */ if (s32Error) { @@ -4042,13 +4034,6 @@ int WILC_WFI_DeInitHostInt(struct net_device *net) struct WILC_WFI_priv *priv; priv = wdev_priv(net->ieee80211_ptr); - - - - - - WILC_SemaphoreDestroy(&(priv->hSemScanReq), NULL); - priv->gbAutoRateAdjusted = WILC_FALSE; priv->bInP2PlistenState = WILC_FALSE; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 0abe653acc66..0fc383b272aa 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -165,8 +165,8 @@ struct WILC_WFI_priv { struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; WILC_Uint8 wilc_groupkey; /* semaphores */ - WILC_SemaphoreHandle SemHandleUpdateStats; - WILC_SemaphoreHandle hSemScanReq; + struct semaphore SemHandleUpdateStats; + struct semaphore hSemScanReq; /* */ WILC_Bool gbAutoRateAdjusted; -- 2.1.0.rc2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel