You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e14af67d8f
commit
83383ea33c
@@ -26,7 +26,7 @@ ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC
|
||||
|
||||
|
||||
wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \
|
||||
wilc_memory.o wilc_msgqueue.o wilc_semaphore.o wilc_sleep.o wilc_strutils.o \
|
||||
wilc_memory.o wilc_msgqueue.o wilc_sleep.o wilc_strutils.o \
|
||||
wilc_timer.o coreconfigurator.o host_interface.o \
|
||||
fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct {
|
||||
WILC_Uint32 u32WriteOffset;
|
||||
WILC_Uint32 u32ReadOffset;
|
||||
WILC_Uint32 u32TotalBytes;
|
||||
WILC_SemaphoreHandle SemBuffer;
|
||||
struct semaphore SemBuffer;
|
||||
} tstrFifoHandler;
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -422,14 +422,14 @@ typedef struct {
|
||||
WILC_Uint8 au8AssociatedBSSID[ETH_ALEN];
|
||||
tstrCfgParamVal strCfgValues;
|
||||
/* semaphores */
|
||||
WILC_SemaphoreHandle gtOsCfgValuesSem;
|
||||
WILC_SemaphoreHandle hSemTestKeyBlock;
|
||||
struct semaphore gtOsCfgValuesSem;
|
||||
struct semaphore hSemTestKeyBlock;
|
||||
|
||||
WILC_SemaphoreHandle hSemTestDisconnectBlock;
|
||||
WILC_SemaphoreHandle hSemGetRSSI;
|
||||
WILC_SemaphoreHandle hSemGetLINKSPEED;
|
||||
WILC_SemaphoreHandle hSemGetCHNL;
|
||||
WILC_SemaphoreHandle hSemInactiveTime;
|
||||
struct semaphore hSemTestDisconnectBlock;
|
||||
struct semaphore hSemGetRSSI;
|
||||
struct semaphore hSemGetLINKSPEED;
|
||||
struct semaphore hSemGetCHNL;
|
||||
struct semaphore hSemInactiveTime;
|
||||
/* timer handlers */
|
||||
WILC_TimerHandle hScanTimer;
|
||||
WILC_TimerHandle hConnectTimer;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user