diff options
Diffstat (limited to 'drivers/staging/ath6kl/htc2')
-rw-r--r-- | drivers/staging/ath6kl/htc2/AR6000/ar6k.c | 411 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/AR6000/ar6k.h | 292 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c | 172 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c | 174 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c | 321 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/htc.c | 138 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/htc_internal.h | 112 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/htc_recv.c | 382 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/htc_send.c | 180 | ||||
-rw-r--r-- | drivers/staging/ath6kl/htc2/htc_services.c | 88 |
10 files changed, 1146 insertions, 1124 deletions
diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k.c index 1efc85c..eeddf60 100644 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k.c +++ b/drivers/staging/ath6kl/htc2/AR6000/ar6k.c @@ -35,21 +35,21 @@ #define MAILBOX_FOR_BLOCK_SIZE 1 -A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev); -A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev); +int DevEnableInterrupts(struct ar6k_device *pDev); +int DevDisableInterrupts(struct ar6k_device *pDev); -static void DevCleanupVirtualScatterSupport(AR6K_DEVICE *pDev); +static void DevCleanupVirtualScatterSupport(struct ar6k_device *pDev); -void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket) +void AR6KFreeIOPacket(struct ar6k_device *pDev, struct htc_packet *pPacket) { LOCK_AR6K(pDev); HTC_PACKET_ENQUEUE(&pDev->RegisterIOList,pPacket); UNLOCK_AR6K(pDev); } -HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev) +struct htc_packet *AR6KAllocIOPacket(struct ar6k_device *pDev) { - HTC_PACKET *pPacket; + struct htc_packet *pPacket; LOCK_AR6K(pDev); pPacket = HTC_PACKET_DEQUEUE(&pDev->RegisterIOList); @@ -58,13 +58,13 @@ HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev) return pPacket; } -void DevCleanup(AR6K_DEVICE *pDev) +void DevCleanup(struct ar6k_device *pDev) { DevCleanupGMbox(pDev); if (pDev->HifAttached) { HIFDetachHTC(pDev->HIFDevice); - pDev->HifAttached = FALSE; + pDev->HifAttached = false; } DevCleanupVirtualScatterSupport(pDev); @@ -74,10 +74,10 @@ void DevCleanup(AR6K_DEVICE *pDev) } } -A_STATUS DevSetup(AR6K_DEVICE *pDev) +int DevSetup(struct ar6k_device *pDev) { - A_UINT32 blocksizes[AR6K_MAILBOXES]; - A_STATUS status = A_OK; + u32 blocksizes[AR6K_MAILBOXES]; + int status = 0; int i; HTC_CALLBACKS htcCallbacks; @@ -96,24 +96,24 @@ A_STATUS DevSetup(AR6K_DEVICE *pDev) status = HIFAttachHTC(pDev->HIFDevice, &htcCallbacks); - if (A_FAILED(status)) { + if (status) { break; } - pDev->HifAttached = TRUE; + pDev->HifAttached = true; /* get the addresses for all 4 mailboxes */ status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR, &pDev->MailBoxInfo, sizeof(pDev->MailBoxInfo)); - if (status != A_OK) { - A_ASSERT(FALSE); + if (status) { + A_ASSERT(false); break; } /* carve up register I/O packets (these are for ASYNC register I/O ) */ for (i = 0; i < AR6K_MAX_REG_IO_BUFFERS; i++) { - HTC_PACKET *pIOPacket; + struct htc_packet *pIOPacket; pIOPacket = &pDev->RegIOBuffers[i].HtcPacket; SET_HTC_PACKET_INFO_RX_REFILL(pIOPacket, pDev, @@ -127,8 +127,8 @@ A_STATUS DevSetup(AR6K_DEVICE *pDev) status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, blocksizes, sizeof(blocksizes)); - if (status != A_OK) { - A_ASSERT(FALSE); + if (status) { + A_ASSERT(false); break; } @@ -174,14 +174,14 @@ A_STATUS DevSetup(AR6K_DEVICE *pDev) AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("HIF requests that DSR yield per %d RECV packets \n", pDev->HifIRQYieldParams.RecvPacketYieldCount)); - pDev->DSRCanYield = TRUE; + pDev->DSRCanYield = true; } break; case HIF_DEVICE_IRQ_ASYNC_SYNC: AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF Interrupt processing is ASYNC and SYNC\n")); break; default: - A_ASSERT(FALSE); + A_ASSERT(false); } pDev->HifMaskUmaskRecvEvent = NULL; @@ -197,18 +197,18 @@ A_STATUS DevSetup(AR6K_DEVICE *pDev) status = DevDisableInterrupts(pDev); - if (A_FAILED(status)) { + if (status) { break; } status = DevSetupGMbox(pDev); - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { if (pDev->HifAttached) { HIFDetachHTC(pDev->HIFDevice); - pDev->HifAttached = FALSE; + pDev->HifAttached = false; } } @@ -216,10 +216,10 @@ A_STATUS DevSetup(AR6K_DEVICE *pDev) } -A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev) +int DevEnableInterrupts(struct ar6k_device *pDev) { - A_STATUS status; - AR6K_IRQ_ENABLE_REGISTERS regs; + int status; + struct ar6k_irq_enable_registers regs; LOCK_AR6K(pDev); @@ -254,7 +254,7 @@ A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev) COUNTER_INT_STATUS_ENABLE_BIT_SET(AR6K_TARGET_DEBUG_INTR_MASK); /* copy into our temp area */ - A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); @@ -266,7 +266,7 @@ A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev) HIF_WR_SYNC_BYTE_INC, NULL); - if (status != A_OK) { + if (status) { /* Can't write it for some reason */ AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to update interrupt control registers err: %d\n", status)); @@ -276,9 +276,9 @@ A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev) return status; } -A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev) +int DevDisableInterrupts(struct ar6k_device *pDev) { - AR6K_IRQ_ENABLE_REGISTERS regs; + struct ar6k_irq_enable_registers regs; LOCK_AR6K(pDev); /* Disable all interrupts */ @@ -287,7 +287,7 @@ A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev) pDev->IrqEnableRegisters.error_status_enable = 0; pDev->IrqEnableRegisters.counter_int_status_enable = 0; /* copy into our temp area */ - A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); @@ -301,7 +301,7 @@ A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev) } /* enable device interrupts */ -A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev) +int DevUnmaskInterrupts(struct ar6k_device *pDev) { /* for good measure, make sure interrupt are disabled before unmasking at the HIF * layer. @@ -309,7 +309,7 @@ A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev) * and when HTC is finally ready to handle interrupts, other software can perform target "soft" resets. * The AR6K interrupt enables reset back to an "enabled" state when this happens. * */ - A_STATUS IntStatus = A_OK; + int IntStatus = 0; DevDisableInterrupts(pDev); #ifdef THREAD_X @@ -327,7 +327,7 @@ A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev) } /* disable all device interrupts */ -A_STATUS DevMaskInterrupts(AR6K_DEVICE *pDev) +int DevMaskInterrupts(struct ar6k_device *pDev) { /* mask the interrupt at the HIF layer, we don't want a stray interrupt taken while * we zero out our shadow registers in DevDisableInterrupts()*/ @@ -337,13 +337,13 @@ A_STATUS DevMaskInterrupts(AR6K_DEVICE *pDev) } /* callback when our fetch to enable/disable completes */ -static void DevDoEnableDisableRecvAsyncHandler(void *Context, HTC_PACKET *pPacket) +static void DevDoEnableDisableRecvAsyncHandler(void *Context, struct htc_packet *pPacket) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; + struct ar6k_device *pDev = (struct ar6k_device *)Context; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDoEnableDisableRecvAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - if (A_FAILED(pPacket->Status)) { + if (pPacket->Status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Failed to disable receiver, status:%d \n", pPacket->Status)); } @@ -355,10 +355,10 @@ static void DevDoEnableDisableRecvAsyncHandler(void *Context, HTC_PACKET *pPacke /* disable packet reception (used in case the host runs out of buffers) * this is the "override" method when the HIF reports another methods to * disable recv events */ -static A_STATUS DevDoEnableDisableRecvOverride(AR6K_DEVICE *pDev, A_BOOL EnableRecv, A_BOOL AsyncMode) +static int DevDoEnableDisableRecvOverride(struct ar6k_device *pDev, bool EnableRecv, bool AsyncMode) { - A_STATUS status = A_OK; - HTC_PACKET *pIOPacket = NULL; + int status = 0; + struct htc_packet *pIOPacket = NULL; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("DevDoEnableDisableRecvOverride: Enable:%d Mode:%d\n", EnableRecv,AsyncMode)); @@ -371,7 +371,7 @@ static A_STATUS DevDoEnableDisableRecvOverride(AR6K_DEVICE *pDev, A_BOOL EnableR if (NULL == pIOPacket) { status = A_NO_MEMORY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -391,9 +391,9 @@ static A_STATUS DevDoEnableDisableRecvOverride(AR6K_DEVICE *pDev, A_BOOL EnableR EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, NULL); - } while (FALSE); + } while (false); - if (A_FAILED(status) && (pIOPacket != NULL)) { + if (status && (pIOPacket != NULL)) { AR6KFreeIOPacket(pDev,pIOPacket); } @@ -403,11 +403,11 @@ static A_STATUS DevDoEnableDisableRecvOverride(AR6K_DEVICE *pDev, A_BOOL EnableR /* disable packet reception (used in case the host runs out of buffers) * this is the "normal" method using the interrupt enable registers through * the host I/F */ -static A_STATUS DevDoEnableDisableRecvNormal(AR6K_DEVICE *pDev, A_BOOL EnableRecv, A_BOOL AsyncMode) +static int DevDoEnableDisableRecvNormal(struct ar6k_device *pDev, bool EnableRecv, bool AsyncMode) { - A_STATUS status = A_OK; - HTC_PACKET *pIOPacket = NULL; - AR6K_IRQ_ENABLE_REGISTERS regs; + int status = 0; + struct htc_packet *pIOPacket = NULL; + struct ar6k_irq_enable_registers regs; /* take the lock to protect interrupt enable shadows */ LOCK_AR6K(pDev); @@ -419,7 +419,7 @@ static A_STATUS DevDoEnableDisableRecvNormal(AR6K_DEVICE *pDev, A_BOOL EnableRec } /* copy into our temp area */ - A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); do { @@ -430,12 +430,12 @@ static A_STATUS DevDoEnableDisableRecvNormal(AR6K_DEVICE *pDev, A_BOOL EnableRec if (NULL == pIOPacket) { status = A_NO_MEMORY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } /* copy values to write to our async I/O buffer */ - A_MEMCPY(pIOPacket->pBuffer,®s,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(pIOPacket->pBuffer,®s,AR6K_IRQ_ENABLE_REGS_SIZE); /* stick in our completion routine when the I/O operation completes */ pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler; @@ -460,9 +460,9 @@ static A_STATUS DevDoEnableDisableRecvNormal(AR6K_DEVICE *pDev, A_BOOL EnableRec HIF_WR_SYNC_BYTE_INC, NULL); - } while (FALSE); + } while (false); - if (A_FAILED(status) && (pIOPacket != NULL)) { + if (status && (pIOPacket != NULL)) { AR6KFreeIOPacket(pDev,pIOPacket); } @@ -470,29 +470,29 @@ static A_STATUS DevDoEnableDisableRecvNormal(AR6K_DEVICE *pDev, A_BOOL EnableRec } -A_STATUS DevStopRecv(AR6K_DEVICE *pDev, A_BOOL AsyncMode) +int DevStopRecv(struct ar6k_device *pDev, bool AsyncMode) { if (NULL == pDev->HifMaskUmaskRecvEvent) { - return DevDoEnableDisableRecvNormal(pDev,FALSE,AsyncMode); + return DevDoEnableDisableRecvNormal(pDev,false,AsyncMode); } else { - return DevDoEnableDisableRecvOverride(pDev,FALSE,AsyncMode); + return DevDoEnableDisableRecvOverride(pDev,false,AsyncMode); } } -A_STATUS DevEnableRecv(AR6K_DEVICE *pDev, A_BOOL AsyncMode) +int DevEnableRecv(struct ar6k_device *pDev, bool AsyncMode) { if (NULL == pDev->HifMaskUmaskRecvEvent) { - return DevDoEnableDisableRecvNormal(pDev,TRUE,AsyncMode); + return DevDoEnableDisableRecvNormal(pDev,true,AsyncMode); } else { - return DevDoEnableDisableRecvOverride(pDev,TRUE,AsyncMode); + return DevDoEnableDisableRecvOverride(pDev,true,AsyncMode); } } -A_STATUS DevWaitForPendingRecv(AR6K_DEVICE *pDev,A_UINT32 TimeoutInMs,A_BOOL *pbIsRecvPending) +int DevWaitForPendingRecv(struct ar6k_device *pDev,u32 TimeoutInMs,bool *pbIsRecvPending) { - A_STATUS status = A_OK; - A_UCHAR host_int_status = 0x0; - A_UINT32 counter = 0x0; + int status = 0; + u8 host_int_status = 0x0; + u32 counter = 0x0; if(TimeoutInMs < 100) { @@ -507,25 +507,25 @@ A_STATUS DevWaitForPendingRecv(AR6K_DEVICE *pDev,A_UINT32 TimeoutInMs,A_BOOL *pb status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, &host_int_status, - sizeof(A_UCHAR), + sizeof(u8), HIF_RD_SYNC_BYTE_INC, NULL); - if(A_FAILED(status)) + if (status) { AR_DEBUG_PRINTF(ATH_LOG_ERR,("DevWaitForPendingRecv:Read HOST_INT_STATUS_ADDRESS Failed 0x%X\n",status)); break; } - host_int_status = A_SUCCESS(status) ? (host_int_status & (1 << 0)):0; + host_int_status = !status ? (host_int_status & (1 << 0)):0; if(!host_int_status) { - status = A_OK; - *pbIsRecvPending = FALSE; + status = 0; + *pbIsRecvPending = false; break; } else { - *pbIsRecvPending = TRUE; + *pbIsRecvPending = true; } A_MDELAY(100); @@ -536,9 +536,9 @@ A_STATUS DevWaitForPendingRecv(AR6K_DEVICE *pDev,A_UINT32 TimeoutInMs,A_BOOL *pb return status; } -void DevDumpRegisters(AR6K_DEVICE *pDev, - AR6K_IRQ_PROC_REGISTERS *pIrqProcRegs, - AR6K_IRQ_ENABLE_REGISTERS *pIrqEnableRegs) +void DevDumpRegisters(struct ar6k_device *pDev, + struct ar6k_irq_proc_registers *pIrqProcRegs, + struct ar6k_irq_enable_registers *pIrqEnableRegs) { AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("\n<------- Register Table -------->\n")); @@ -585,39 +585,39 @@ void DevDumpRegisters(AR6K_DEVICE *pDev, } -#define DEV_GET_VIRT_DMA_INFO(p) ((DEV_SCATTER_DMA_VIRTUAL_INFO *)((p)->HIFPrivate[0])) +#define DEV_GET_VIRT_DMA_INFO(p) ((struct dev_scatter_dma_virtual_info *)((p)->HIFPrivate[0])) -static HIF_SCATTER_REQ *DevAllocScatterReq(HIF_DEVICE *Context) +static struct hif_scatter_req *DevAllocScatterReq(struct hif_device *Context) { - DL_LIST *pItem; - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; + struct dl_list *pItem; + struct ar6k_device *pDev = (struct ar6k_device *)Context; LOCK_AR6K(pDev); pItem = DL_ListRemoveItemFromHead(&pDev->ScatterReqHead); UNLOCK_AR6K(pDev); if (pItem != NULL) { - return A_CONTAINING_STRUCT(pItem, HIF_SCATTER_REQ, ListLink); + return A_CONTAINING_STRUCT(pItem, struct hif_scatter_req, ListLink); } return NULL; } -static void DevFreeScatterReq(HIF_DEVICE *Context, HIF_SCATTER_REQ *pReq) +static void DevFreeScatterReq(struct hif_device *Context, struct hif_scatter_req *pReq) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; + struct ar6k_device *pDev = (struct ar6k_device *)Context; LOCK_AR6K(pDev); DL_ListInsertTail(&pDev->ScatterReqHead, &pReq->ListLink); UNLOCK_AR6K(pDev); } -A_STATUS DevCopyScatterListToFromDMABuffer(HIF_SCATTER_REQ *pReq, A_BOOL FromDMA) +int DevCopyScatterListToFromDMABuffer(struct hif_scatter_req *pReq, bool FromDMA) { - A_UINT8 *pDMABuffer = NULL; + u8 *pDMABuffer = NULL; int i, remaining; - A_UINT32 length; + u32 length; pDMABuffer = pReq->pScatterBounceBuffer; if (pDMABuffer == NULL) { - A_ASSERT(FALSE); + A_ASSERT(false); return A_EINVAL; } @@ -628,30 +628,30 @@ A_STATUS DevCopyScatterListToFromDMABuffer(HIF_SCATTER_REQ *pReq, A_BOOL FromDMA length = min((int)pReq->ScatterList[i].Length, remaining); if (length != (int)pReq->ScatterList[i].Length) { - A_ASSERT(FALSE); + A_ASSERT(false); /* there is a problem with the scatter list */ return A_EINVAL; } if (FromDMA) { /* from DMA buffer */ - A_MEMCPY(pReq->ScatterList[i].pBuffer, pDMABuffer , length); + memcpy(pReq->ScatterList[i].pBuffer, pDMABuffer , length); } else { /* to DMA buffer */ - A_MEMCPY(pDMABuffer, pReq->ScatterList[i].pBuffer, length); + memcpy(pDMABuffer, pReq->ScatterList[i].pBuffer, length); } pDMABuffer += length; remaining -= length; } - return A_OK; + return 0; } -static void DevReadWriteScatterAsyncHandler(void *Context, HTC_PACKET *pPacket) +static void DevReadWriteScatterAsyncHandler(void *Context, struct htc_packet *pPacket) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; - HIF_SCATTER_REQ *pReq = (HIF_SCATTER_REQ *)pPacket->pPktContext; + struct ar6k_device *pDev = (struct ar6k_device *)Context; + struct hif_scatter_req *pReq = (struct hif_scatter_req *)pPacket->pPktContext; AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+DevReadWriteScatterAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); @@ -664,12 +664,12 @@ static void DevReadWriteScatterAsyncHandler(void *Context, HTC_PACKET *pPacket) AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-DevReadWriteScatterAsyncHandler \n")); } -static A_STATUS DevReadWriteScatter(HIF_DEVICE *Context, HIF_SCATTER_REQ *pReq) +static int DevReadWriteScatter(struct hif_device *Context, struct hif_scatter_req *pReq) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; - A_STATUS status = A_OK; - HTC_PACKET *pIOPacket = NULL; - A_UINT32 request = pReq->Request; + struct ar6k_device *pDev = (struct ar6k_device *)Context; + int status = 0; + struct htc_packet *pIOPacket = NULL; + u32 request = pReq->Request; do { @@ -680,7 +680,7 @@ static A_STATUS DevReadWriteScatter(HIF_DEVICE *Context, HIF_SCATTER_REQ *pReq) } if (pReq->TotalLength == 0) { - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -719,27 +719,27 @@ static A_STATUS DevReadWriteScatter(HIF_DEVICE *Context, HIF_SCATTER_REQ *pReq) request, (request & HIF_ASYNCHRONOUS) ? pIOPacket : NULL); - } while (FALSE); + } while (false); - if ((status != A_PENDING) && A_FAILED(status) && (request & HIF_ASYNCHRONOUS)) { + if ((status != A_PENDING) && status && (request & HIF_ASYNCHRONOUS)) { if (pIOPacket != NULL) { AR6KFreeIOPacket(pDev,pIOPacket); } pReq->CompletionStatus = status; pReq->CompletionRoutine(pReq); - status = A_OK; + status = 0; } return status; } -static void DevCleanupVirtualScatterSupport(AR6K_DEVICE *pDev) +static void DevCleanupVirtualScatterSupport(struct ar6k_device *pDev) { - HIF_SCATTER_REQ *pReq; + struct hif_scatter_req *pReq; while (1) { - pReq = DevAllocScatterReq((HIF_DEVICE *)pDev); + pReq = DevAllocScatterReq((struct hif_device *)pDev); if (NULL == pReq) { break; } @@ -749,23 +749,23 @@ static void DevCleanupVirtualScatterSupport(AR6K_DEVICE *pDev) } /* function to set up virtual scatter support if HIF layer has not implemented the interface */ -static A_STATUS DevSetupVirtualScatterSupport(AR6K_DEVICE *pDev) +static int DevSetupVirtualScatterSupport(struct ar6k_device *pDev) { - A_STATUS status = A_OK; + int status = 0; int bufferSize, sgreqSize; int i; - DEV_SCATTER_DMA_VIRTUAL_INFO *pVirtualInfo; - HIF_SCATTER_REQ *pReq; + struct dev_scatter_dma_virtual_info *pVirtualInfo; + struct hif_scatter_req *pReq; - bufferSize = sizeof(DEV_SCATTER_DMA_VIRTUAL_INFO) + + bufferSize = sizeof(struct dev_scatter_dma_virtual_info) + 2 * (A_GET_CACHE_LINE_BYTES()) + AR6K_MAX_TRANSFER_SIZE_PER_SCATTER; - sgreqSize = sizeof(HIF_SCATTER_REQ) + - (AR6K_SCATTER_ENTRIES_PER_REQ - 1) * (sizeof(HIF_SCATTER_ITEM)); + sgreqSize = sizeof(struct hif_scatter_req) + + (AR6K_SCATTER_ENTRIES_PER_REQ - 1) * (sizeof(struct hif_scatter_item)); for (i = 0; i < AR6K_SCATTER_REQS; i++) { /* allocate the scatter request, buffer info and the actual virtual buffer itself */ - pReq = (HIF_SCATTER_REQ *)A_MALLOC(sgreqSize + bufferSize); + pReq = (struct hif_scatter_req *)A_MALLOC(sgreqSize + bufferSize); if (NULL == pReq) { status = A_NO_MEMORY; @@ -775,8 +775,8 @@ static A_STATUS DevSetupVirtualScatterSupport(AR6K_DEVICE *pDev) A_MEMZERO(pReq, sgreqSize); /* the virtual DMA starts after the scatter request struct */ - pVirtualInfo = (DEV_SCATTER_DMA_VIRTUAL_INFO *)((A_UINT8 *)pReq + sgreqSize); - A_MEMZERO(pVirtualInfo, sizeof(DEV_SCATTER_DMA_VIRTUAL_INFO)); + pVirtualInfo = (struct dev_scatter_dma_virtual_info *)((u8 *)pReq + sgreqSize); + A_MEMZERO(pVirtualInfo, sizeof(struct dev_scatter_dma_virtual_info)); pVirtualInfo->pVirtDmaBuffer = &pVirtualInfo->DataArea[0]; /* align buffer to cache line in case host controller can actually DMA this */ @@ -787,10 +787,10 @@ static A_STATUS DevSetupVirtualScatterSupport(AR6K_DEVICE *pDev) pReq->ScatterMethod = HIF_SCATTER_DMA_BOUNCE; pReq->pScatterBounceBuffer = pVirtualInfo->pVirtDmaBuffer; /* free request to the list */ - DevFreeScatterReq((HIF_DEVICE *)pDev,pReq); + DevFreeScatterReq((struct hif_device *)pDev,pReq); } - if (A_FAILED(status)) { + if (status) { DevCleanupVirtualScatterSupport(pDev); } else { pDev->HifScatterInfo.pAllocateReqFunc = DevAllocScatterReq; @@ -804,16 +804,25 @@ static A_STATUS DevSetupVirtualScatterSupport(AR6K_DEVICE *pDev) pDev->HifScatterInfo.MaxScatterEntries = AR6K_SCATTER_ENTRIES_PER_REQ; pDev->HifScatterInfo.MaxTransferSizePerScatterReq = AR6K_MAX_TRANSFER_SIZE_PER_SCATTER; } - pDev->ScatterIsVirtual = TRUE; + pDev->ScatterIsVirtual = true; } return status; } +int DevCleanupMsgBundling(struct ar6k_device *pDev) +{ + if(NULL != pDev) + { + DevCleanupVirtualScatterSupport(pDev); + } + + return 0; +} -A_STATUS DevSetupMsgBundling(AR6K_DEVICE *pDev, int MaxMsgsPerTransfer) +int DevSetupMsgBundling(struct ar6k_device *pDev, int MaxMsgsPerTransfer) { - A_STATUS status; + int status; if (pDev->MailBoxInfo.Flags & HIF_MBOX_FLAG_NO_BUNDLING) { AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("HIF requires bundling disabled\n")); @@ -825,14 +834,14 @@ A_STATUS DevSetupMsgBundling(AR6K_DEVICE *pDev, int MaxMsgsPerTransfer) &pDev->HifScatterInfo, sizeof(pDev->HifScatterInfo)); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("AR6K: ** HIF layer does not support scatter requests (%d) \n",status)); /* we can try to use a virtual DMA scatter mechanism using legacy HIFReadWrite() */ status = DevSetupVirtualScatterSupport(pDev); - if (A_SUCCESS(status)) { + if (!status) { AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("AR6K: virtual scatter transfers enabled (max scatter items:%d: maxlen:%d) \n", DEV_GET_MAX_MSG_PER_BUNDLE(pDev), DEV_GET_MAX_BUNDLE_LENGTH(pDev))); @@ -844,7 +853,7 @@ A_STATUS DevSetupMsgBundling(AR6K_DEVICE *pDev, int MaxMsgsPerTransfer) DEV_GET_MAX_MSG_PER_BUNDLE(pDev), DEV_GET_MAX_BUNDLE_LENGTH(pDev))); } - if (A_SUCCESS(status)) { + if (!status) { /* for the recv path, the maximum number of bytes per recv bundle is just limited * by the maximum transfer size at the HIF layer */ pDev->MaxRecvBundleSize = pDev->HifScatterInfo.MaxTransferSizePerScatterReq; @@ -876,21 +885,21 @@ A_STATUS DevSetupMsgBundling(AR6K_DEVICE *pDev, int MaxMsgsPerTransfer) return status; } -A_STATUS DevSubmitScatterRequest(AR6K_DEVICE *pDev, HIF_SCATTER_REQ *pScatterReq, A_BOOL Read, A_BOOL Async) +int DevSubmitScatterRequest(struct ar6k_device *pDev, struct hif_scatter_req *pScatterReq, bool Read, bool Async) { - A_STATUS status; + int status; if (Read) { /* read operation */ pScatterReq->Request = (Async) ? HIF_RD_ASYNC_BLOCK_FIX : HIF_RD_SYNC_BLOCK_FIX; pScatterReq->Address = pDev->MailBoxInfo.MboxAddresses[HTC_MAILBOX]; - A_ASSERT(pScatterReq->TotalLength <= (A_UINT32)DEV_GET_MAX_BUNDLE_RECV_LENGTH(pDev)); + A_ASSERT(pScatterReq->TotalLength <= (u32)DEV_GET_MAX_BUNDLE_RECV_LENGTH(pDev)); } else { - A_UINT32 mailboxWidth; + u32 mailboxWidth; /* write operation */ pScatterReq->Request = (Async) ? HIF_WR_ASYNC_BLOCK_INC : HIF_WR_SYNC_BLOCK_INC; - A_ASSERT(pScatterReq->TotalLength <= (A_UINT32)DEV_GET_MAX_BUNDLE_SEND_LENGTH(pDev)); + A_ASSERT(pScatterReq->TotalLength <= (u32)DEV_GET_MAX_BUNDLE_SEND_LENGTH(pDev)); if (pScatterReq->TotalLength > AR6K_LEGACY_MAX_WRITE_LENGTH) { /* for large writes use the extended address */ pScatterReq->Address = pDev->MailBoxInfo.MboxProp[HTC_MAILBOX].ExtendedAddress; @@ -919,11 +928,11 @@ A_STATUS DevSubmitScatterRequest(AR6K_DEVICE *pDev, HIF_SCATTER_REQ *pScatterReq status = DEV_PREPARE_SCATTER_OPERATION(pScatterReq); - if (A_FAILED(status)) { + if (status) { if (Async) { pScatterReq->CompletionStatus = status; pScatterReq->CompletionRoutine(pScatterReq); - return A_OK; + return 0; } return status; } @@ -936,7 +945,7 @@ A_STATUS DevSubmitScatterRequest(AR6K_DEVICE *pDev, HIF_SCATTER_REQ *pScatterReq DEV_FINISH_SCATTER_OPERATION(pScatterReq); } else { if (status == A_PENDING) { - status = A_OK; + status = 0; } } @@ -1002,16 +1011,16 @@ A_STATUS DevSubmitScatterRequest(AR6K_DEVICE *pDev, HIF_SCATTER_REQ *pScatterReq #define TEST_CREDITS_RECV_TIMEOUT 100 -static A_UINT8 g_Buffer[TOTAL_BYTES]; -static A_UINT32 g_MailboxAddrs[AR6K_MAILBOXES]; -static A_UINT32 g_BlockSizes[AR6K_MAILBOXES]; +static u8 g_Buffer[TOTAL_BYTES]; +static u32 g_MailboxAddrs[AR6K_MAILBOXES]; +static u32 g_BlockSizes[AR6K_MAILBOXES]; #define BUFFER_PROC_LIST_DEPTH 4 -typedef struct _BUFFER_PROC_LIST{ - A_UINT8 *pBuffer; - A_UINT32 length; -}BUFFER_PROC_LIST; +struct buffer_proc_list { + u8 *pBuffer; + u32 length; +}; #define PUSH_BUFF_PROC_ENTRY(pList,len,pCurrpos) \ @@ -1023,9 +1032,9 @@ typedef struct _BUFFER_PROC_LIST{ } /* a simple and crude way to send different "message" sizes */ -static void AssembleBufferList(BUFFER_PROC_LIST *pList) +static void AssembleBufferList(struct buffer_proc_list *pList) { - A_UINT8 *pBuffer = g_Buffer; + u8 *pBuffer = g_Buffer; #if BUFFER_PROC_LIST_DEPTH < 4 #error "Buffer processing list depth is not deep enough!!" @@ -1038,17 +1047,17 @@ static void AssembleBufferList(BUFFER_PROC_LIST *pList) } -#define FILL_ZERO TRUE -#define FILL_COUNTING FALSE -static void InitBuffers(A_BOOL Zero) +#define FILL_ZERO true +#define FILL_COUNTING false +static void InitBuffers(bool Zero) { - A_UINT16 *pBuffer16 = (A_UINT16 *)g_Buffer; + u16 *pBuffer16 = (u16 *)g_Buffer; int i; /* fill buffer with 16 bit counting pattern or zeros */ for (i = 0; i < (TOTAL_BYTES / 2) ; i++) { if (!Zero) { - pBuffer16[i] = (A_UINT16)i; + pBuffer16[i] = (u16)i; } else { pBuffer16[i] = 0; } @@ -1056,11 +1065,11 @@ static void InitBuffers(A_BOOL Zero) } -static A_BOOL CheckOneBuffer(A_UINT16 *pBuffer16, int Length) +static bool CheckOneBuffer(u16 *pBuffer16, int Length) { int i; - A_UINT16 startCount; - A_BOOL success = TRUE; + u16 startCount; + bool success = true; /* get the starting count */ startCount = pBuffer16[0]; @@ -1069,10 +1078,10 @@ static A_BOOL CheckOneBuffer(A_UINT16 *pBuffer16, int Length) /* scan the buffer and verify */ for (i = 0; i < (Length / 2) ; i++,startCount++) { /* target will invert all the data */ - if ((A_UINT16)pBuffer16[i] != (A_UINT16)~startCount) { - success = FALSE; + if ((u16)pBuffer16[i] != (u16)~startCount) { + success = false; AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Invalid Data Got:0x%X, Expecting:0x%X (offset:%d, total:%d) \n", - pBuffer16[i], ((A_UINT16)~startCount), i, Length)); + pBuffer16[i], ((u16)~startCount), i, Length)); AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("0x%X 0x%X 0x%X 0x%X \n", pBuffer16[i], pBuffer16[i + 1], pBuffer16[i + 2],pBuffer16[i+3])); break; @@ -1082,21 +1091,21 @@ static A_BOOL CheckOneBuffer(A_UINT16 *pBuffer16, int Length) return success; } -static A_BOOL CheckBuffers(void) +static bool CheckBuffers(void) { int i; - A_BOOL success = TRUE; - BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH]; + bool success = true; + struct buffer_proc_list checkList[BUFFER_PROC_LIST_DEPTH]; /* assemble the list */ AssembleBufferList(checkList); /* scan the buffers and verify */ for (i = 0; i < BUFFER_PROC_LIST_DEPTH ; i++) { - success = CheckOneBuffer((A_UINT16 *)checkList[i].pBuffer, checkList[i].length); + success = CheckOneBuffer((u16 *)checkList[i].pBuffer, checkList[i].length); if (!success) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer : 0x%X, Length:%d failed verify \n", - (A_UINT32)checkList[i].pBuffer, checkList[i].length)); + (u32)checkList[i].pBuffer, checkList[i].length)); break; } } @@ -1105,10 +1114,10 @@ static A_BOOL CheckBuffers(void) } /* find the end marker for the last buffer we will be sending */ -static A_UINT16 GetEndMarker(void) +static u16 GetEndMarker(void) { - A_UINT8 *pBuffer; - BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH]; + u8 *pBuffer; + struct buffer_proc_list checkList[BUFFER_PROC_LIST_DEPTH]; /* fill up buffers with the normal counting pattern */ InitBuffers(FILL_COUNTING); @@ -1119,17 +1128,17 @@ static A_UINT16 GetEndMarker(void) pBuffer = &(checkList[BUFFER_PROC_LIST_DEPTH - 1].pBuffer[(checkList[BUFFER_PROC_LIST_DEPTH - 1].length) - 2]); /* the last count in the last buffer is the marker */ - return (A_UINT16)pBuffer[0] | ((A_UINT16)pBuffer[1] << 8); + return (u16)pBuffer[0] | ((u16)pBuffer[1] << 8); } #define ATH_PRINT_OUT_ZONE ATH_DEBUG_ERR /* send the ordered buffers to the target */ -static A_STATUS SendBuffers(AR6K_DEVICE *pDev, int mbox) +static int SendBuffers(struct ar6k_device *pDev, int mbox) { - A_STATUS status = A_OK; - A_UINT32 request = HIF_WR_SYNC_BLOCK_INC; - BUFFER_PROC_LIST sendList[BUFFER_PROC_LIST_DEPTH]; + int status = 0; + u32 request = HIF_WR_SYNC_BLOCK_INC; + struct buffer_proc_list sendList[BUFFER_PROC_LIST_DEPTH]; int i; int totalBytes = 0; int paddedLength; @@ -1156,7 +1165,7 @@ static A_STATUS SendBuffers(AR6K_DEVICE *pDev, int mbox) paddedLength, request, NULL); - if (status != A_OK) { + if (status) { break; } totalBytes += sendList[i].length; @@ -1169,20 +1178,20 @@ static A_STATUS SendBuffers(AR6K_DEVICE *pDev, int mbox) } /* poll the mailbox credit counter until we get a credit or timeout */ -static A_STATUS GetCredits(AR6K_DEVICE *pDev, int mbox, int *pCredits) +static int GetCredits(struct ar6k_device *pDev, int mbox, int *pCredits) { - A_STATUS status = A_OK; + int status = 0; int timeout = TEST_CREDITS_RECV_TIMEOUT; - A_UINT8 credits = 0; - A_UINT32 address; + u8 credits = 0; + u32 address; - while (TRUE) { + while (true) { /* Read the counter register to get credits, this auto-decrements */ address = COUNT_DEC_ADDRESS + (AR6K_MAILBOXES + mbox) * 4; status = HIFReadWrite(pDev->HIFDevice, address, &credits, sizeof(credits), HIF_RD_SYNC_BYTE_FIX, NULL); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to decrement the command credit count register (mbox=%d)\n",mbox)); status = A_ERROR; @@ -1207,7 +1216,7 @@ static A_STATUS GetCredits(AR6K_DEVICE *pDev, int mbox, int *pCredits) } - if (status == A_OK) { + if (status == 0) { *pCredits = credits; } @@ -1216,11 +1225,11 @@ static A_STATUS GetCredits(AR6K_DEVICE *pDev, int mbox, int *pCredits) /* wait for the buffers to come back */ -static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) +static int RecvBuffers(struct ar6k_device *pDev, int mbox) { - A_STATUS status = A_OK; - A_UINT32 request = HIF_RD_SYNC_BLOCK_INC; - BUFFER_PROC_LIST recvList[BUFFER_PROC_LIST_DEPTH]; + int status = 0; + u32 request = HIF_RD_SYNC_BLOCK_INC; + struct buffer_proc_list recvList[BUFFER_PROC_LIST_DEPTH]; int curBuffer; int credits; int i; @@ -1244,7 +1253,7 @@ static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) * until we get at least 1 credit or it times out */ status = GetCredits(pDev, mbox, &credits); - if (status != A_OK) { + if (status) { break; } @@ -1264,7 +1273,7 @@ static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) paddedLength, request, NULL); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to read %d bytes on mailbox:%d : address:0x%X \n", recvList[curBuffer].length, mbox, g_MailboxAddrs[mbox])); break; @@ -1275,7 +1284,7 @@ static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) curBuffer++; } - if (status != A_OK) { + if (status) { break; } /* go back and get some more */ @@ -1283,7 +1292,7 @@ static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) } if (totalBytes != TEST_BYTES) { - A_ASSERT(FALSE); + A_ASSERT(false); } else { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got all buffers on mbox:%d total recv :%d (w/Padding : %d) \n", mbox, totalBytes, totalwPadding)); @@ -1294,15 +1303,15 @@ static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) } -static A_STATUS DoOneMboxHWTest(AR6K_DEVICE *pDev, int mbox) +static int DoOneMboxHWTest(struct ar6k_device *pDev, int mbox) { - A_STATUS status; + int status; do { /* send out buffers */ status = SendBuffers(pDev,mbox); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Sending buffers Failed : %d mbox:%d\n",status,mbox)); break; } @@ -1310,7 +1319,7 @@ static A_STATUS DoOneMboxHWTest(AR6K_DEVICE *pDev, int mbox) /* go get them, this will block */ status = RecvBuffers(pDev, mbox); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Recv buffers Failed : %d mbox:%d\n",status,mbox)); break; } @@ -1324,21 +1333,21 @@ static A_STATUS DoOneMboxHWTest(AR6K_DEVICE *pDev, int mbox) AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" Send/Recv success! mailbox : %d \n",mbox)); - } while (FALSE); + } while (false); return status; } /* here is where the test starts */ -A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) +int DoMboxHWTest(struct ar6k_device *pDev) { int i; - A_STATUS status; + int status; int credits = 0; - A_UINT8 params[4]; + u8 params[4]; int numBufs; int bufferSize; - A_UINT16 temp; + u16 temp; AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest START - \n")); @@ -1348,8 +1357,8 @@ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR, g_MailboxAddrs, sizeof(g_MailboxAddrs)); - if (status != A_OK) { - A_ASSERT(FALSE); + if (status) { + A_ASSERT(false); break; } @@ -1357,8 +1366,8 @@ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, g_BlockSizes, sizeof(g_BlockSizes)); - if (status != A_OK) { - A_ASSERT(FALSE); + if (status) { + A_ASSERT(false); break; } @@ -1380,7 +1389,7 @@ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) * mailbox 0 */ status = GetCredits(pDev, 0, &credits); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait for target ready \n")); break; } @@ -1395,13 +1404,13 @@ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) HIF_RD_SYNC_BYTE_INC, NULL); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait get parameters \n")); break; } numBufs = params[0]; - bufferSize = (int)(((A_UINT16)params[2] << 8) | (A_UINT16)params[1]); + bufferSize = (int)(((u16)params[2] << 8) | (u16)params[1]); AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Target parameters: bufs per mailbox:%d, buffer size:%d bytes (total space: %d, minimum required space (w/padding): %d) \n", @@ -1418,29 +1427,29 @@ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) status = HIFReadWrite(pDev->HIFDevice, SCRATCH_ADDRESS + 4, - (A_UINT8 *)&temp, + (u8 *)&temp, 2, HIF_WR_SYNC_BYTE_INC, NULL); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write end marker \n")); break; } AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("End Marker: 0x%X \n",temp)); - temp = (A_UINT16)g_BlockSizes[1]; + temp = (u16)g_BlockSizes[1]; /* convert to a mask */ temp = temp - 1; status = HIFReadWrite(pDev->HIFDevice, SCRATCH_ADDRESS + 6, - (A_UINT8 *)&temp, + (u8 *)&temp, 2, HIF_WR_SYNC_BYTE_INC, NULL); - if (status != A_OK) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write block mask \n")); break; } @@ -1450,14 +1459,14 @@ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) /* execute the test on each mailbox */ for (i = 0; i < AR6K_MAILBOXES; i++) { status = DoOneMboxHWTest(pDev, i); - if (status != A_OK) { + if (status) { break; } } - } while (FALSE); + } while (false); - if (status == A_OK) { + if (status == 0) { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - SUCCESS! - \n")); } else { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - FAILED! - \n")); diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k.h b/drivers/staging/ath6kl/htc2/AR6000/ar6k.h index b30fd87..1ff2218 100644 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k.h +++ b/drivers/staging/ath6kl/htc2/AR6000/ar6k.h @@ -43,40 +43,40 @@ //#define MBOXHW_UNIT_TEST 1 #include "athstartpack.h" -typedef PREPACK struct _AR6K_IRQ_PROC_REGISTERS { - A_UINT8 host_int_status; - A_UINT8 cpu_int_status; - A_UINT8 error_int_status; - A_UINT8 counter_int_status; - A_UINT8 mbox_frame; - A_UINT8 rx_lookahead_valid; - A_UINT8 host_int_status2; - A_UINT8 gmbox_rx_avail; - A_UINT32 rx_lookahead[2]; - A_UINT32 rx_gmbox_lookahead_alias[2]; -} POSTPACK AR6K_IRQ_PROC_REGISTERS; - -#define AR6K_IRQ_PROC_REGS_SIZE sizeof(AR6K_IRQ_PROC_REGISTERS) - -typedef PREPACK struct _AR6K_IRQ_ENABLE_REGISTERS { - A_UINT8 int_status_enable; - A_UINT8 cpu_int_status_enable; - A_UINT8 error_status_enable; - A_UINT8 counter_int_status_enable; -} POSTPACK AR6K_IRQ_ENABLE_REGISTERS; - -typedef PREPACK struct _AR6K_GMBOX_CTRL_REGISTERS { - A_UINT8 int_status_enable; -} POSTPACK AR6K_GMBOX_CTRL_REGISTERS; +PREPACK struct ar6k_irq_proc_registers { + u8 host_int_status; + u8 cpu_int_status; + u8 error_int_status; + u8 counter_int_status; + u8 mbox_frame; + u8 rx_lookahead_valid; + u8 host_int_status2; + u8 gmbox_rx_avail; + u32 rx_lookahead[2]; + u32 rx_gmbox_lookahead_alias[2]; +} POSTPACK; + +#define AR6K_IRQ_PROC_REGS_SIZE sizeof(struct ar6k_irq_proc_registers) + +PREPACK struct ar6k_irq_enable_registers { + u8 int_status_enable; + u8 cpu_int_status_enable; + u8 error_status_enable; + u8 counter_int_status_enable; +} POSTPACK; + +PREPACK struct ar6k_gmbox_ctrl_registers { + u8 int_status_enable; +} POSTPACK; #include "athendpack.h" -#define AR6K_IRQ_ENABLE_REGS_SIZE sizeof(AR6K_IRQ_ENABLE_REGISTERS) +#define AR6K_IRQ_ENABLE_REGS_SIZE sizeof(struct ar6k_irq_enable_registers) #define AR6K_REG_IO_BUFFER_SIZE 32 #define AR6K_MAX_REG_IO_BUFFERS 8 -#define FROM_DMA_BUFFER TRUE -#define TO_DMA_BUFFER FALSE +#define FROM_DMA_BUFFER true +#define TO_DMA_BUFFER false #define AR6K_SCATTER_ENTRIES_PER_REQ 16 #define AR6K_MAX_TRANSFER_SIZE_PER_SCATTER 16*1024 #define AR6K_SCATTER_REQS 4 @@ -89,107 +89,107 @@ typedef PREPACK struct _AR6K_GMBOX_CTRL_REGISTERS { #define AR6K_MIN_TRANSFER_SIZE_PER_SCATTER 4*1024 /* buffers for ASYNC I/O */ -typedef struct AR6K_ASYNC_REG_IO_BUFFER { - HTC_PACKET HtcPacket; /* we use an HTC packet as a wrapper for our async register-based I/O */ - A_UINT8 _Pad1[A_CACHE_LINE_PAD]; - A_UINT8 Buffer[AR6K_REG_IO_BUFFER_SIZE]; /* cache-line safe with pads around */ - A_UINT8 _Pad2[A_CACHE_LINE_PAD]; -} AR6K_ASYNC_REG_IO_BUFFER; - -typedef struct _AR6K_GMBOX_INFO { +struct ar6k_async_reg_io_buffer { + struct htc_packet HtcPacket; /* we use an HTC packet as a wrapper for our async register-based I/O */ + u8 _Pad1[A_CACHE_LINE_PAD]; + u8 Buffer[AR6K_REG_IO_BUFFER_SIZE]; /* cache-line safe with pads around */ + u8 _Pad2[A_CACHE_LINE_PAD]; +}; + +struct ar6k_gmbox_info { void *pProtocolContext; - A_STATUS (*pMessagePendingCallBack)(void *pContext, A_UINT8 LookAheadBytes[], int ValidBytes); - A_STATUS (*pCreditsPendingCallback)(void *pContext, int NumCredits, A_BOOL CreditIRQEnabled); - void (*pTargetFailureCallback)(void *pContext, A_STATUS Status); + int (*pMessagePendingCallBack)(void *pContext, u8 LookAheadBytes[], int ValidBytes); + int (*pCreditsPendingCallback)(void *pContext, int NumCredits, bool CreditIRQEnabled); + void (*pTargetFailureCallback)(void *pContext, int Status); void (*pStateDumpCallback)(void *pContext); - A_BOOL CreditCountIRQEnabled; -} AR6K_GMBOX_INFO; + bool CreditCountIRQEnabled; +}; -typedef struct _AR6K_DEVICE { +struct ar6k_device { A_MUTEX_T Lock; - A_UINT8 _Pad1[A_CACHE_LINE_PAD]; - AR6K_IRQ_PROC_REGISTERS IrqProcRegisters; /* cache-line safe with pads around */ - A_UINT8 _Pad2[A_CACHE_LINE_PAD]; - AR6K_IRQ_ENABLE_REGISTERS IrqEnableRegisters; /* cache-line safe with pads around */ - A_UINT8 _Pad3[A_CACHE_LINE_PAD]; + u8 _Pad1[A_CACHE_LINE_PAD]; + struct ar6k_irq_proc_registers IrqProcRegisters; /* cache-line safe with pads around */ + u8 _Pad2[A_CACHE_LINE_PAD]; + struct ar6k_irq_enable_registers IrqEnableRegisters; /* cache-line safe with pads around */ + u8 _Pad3[A_CACHE_LINE_PAD]; void *HIFDevice; - A_UINT32 BlockSize; - A_UINT32 BlockMask; - HIF_DEVICE_MBOX_INFO MailBoxInfo; + u32 BlockSize; + u32 BlockMask; + struct hif_device_mbox_info MailBoxInfo; HIF_PENDING_EVENTS_FUNC GetPendingEventsFunc; void *HTCContext; - HTC_PACKET_QUEUE RegisterIOList; - AR6K_ASYNC_REG_IO_BUFFER RegIOBuffers[AR6K_MAX_REG_IO_BUFFERS]; + struct htc_packet_queue RegisterIOList; + struct ar6k_async_reg_io_buffer RegIOBuffers[AR6K_MAX_REG_IO_BUFFERS]; void (*TargetFailureCallback)(void *Context); - A_STATUS (*MessagePendingCallback)(void *Context, - A_UINT32 LookAheads[], + int (*MessagePendingCallback)(void *Context, + u32 LookAheads[], int NumLookAheads, - A_BOOL *pAsyncProc, + bool *pAsyncProc, int *pNumPktsFetched); HIF_DEVICE_IRQ_PROCESSING_MODE HifIRQProcessingMode; HIF_MASK_UNMASK_RECV_EVENT HifMaskUmaskRecvEvent; - A_BOOL HifAttached; - HIF_DEVICE_IRQ_YIELD_PARAMS HifIRQYieldParams; - A_BOOL DSRCanYield; + bool HifAttached; + struct hif_device_irq_yield_params HifIRQYieldParams; + bool DSRCanYield; int CurrentDSRRecvCount; - HIF_DEVICE_SCATTER_SUPPORT_INFO HifScatterInfo; - DL_LIST ScatterReqHead; - A_BOOL ScatterIsVirtual; + struct hif_device_scatter_support_info HifScatterInfo; + struct dl_list ScatterReqHead; + bool ScatterIsVirtual; int MaxRecvBundleSize; int MaxSendBundleSize; - AR6K_GMBOX_INFO GMboxInfo; - A_BOOL GMboxEnabled; - AR6K_GMBOX_CTRL_REGISTERS GMboxControlRegisters; + struct ar6k_gmbox_info GMboxInfo; + bool GMboxEnabled; + struct ar6k_gmbox_ctrl_registers GMboxControlRegisters; int RecheckIRQStatusCnt; -} AR6K_DEVICE; +}; #define LOCK_AR6K(p) A_MUTEX_LOCK(&(p)->Lock); #define UNLOCK_AR6K(p) A_MUTEX_UNLOCK(&(p)->Lock); #define REF_IRQ_STATUS_RECHECK(p) (p)->RecheckIRQStatusCnt = 1 /* note: no need to lock this, it only gets set */ -A_STATUS DevSetup(AR6K_DEVICE *pDev); -void DevCleanup(AR6K_DEVICE *pDev); -A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev); -A_STATUS DevMaskInterrupts(AR6K_DEVICE *pDev); -A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev, - A_UINT32 *pLookAhead, +int DevSetup(struct ar6k_device *pDev); +void DevCleanup(struct ar6k_device *pDev); +int DevUnmaskInterrupts(struct ar6k_device *pDev); +int DevMaskInterrupts(struct ar6k_device *pDev); +int DevPollMboxMsgRecv(struct ar6k_device *pDev, + u32 *pLookAhead, int TimeoutMS); -A_STATUS DevRWCompletionHandler(void *context, A_STATUS status); -A_STATUS DevDsrHandler(void *context); -A_STATUS DevCheckPendingRecvMsgsAsync(void *context); -void DevAsyncIrqProcessComplete(AR6K_DEVICE *pDev); -void DevDumpRegisters(AR6K_DEVICE *pDev, - AR6K_IRQ_PROC_REGISTERS *pIrqProcRegs, - AR6K_IRQ_ENABLE_REGISTERS *pIrqEnableRegs); - -#define DEV_STOP_RECV_ASYNC TRUE -#define DEV_STOP_RECV_SYNC FALSE -#define DEV_ENABLE_RECV_ASYNC TRUE -#define DEV_ENABLE_RECV_SYNC FALSE -A_STATUS DevStopRecv(AR6K_DEVICE *pDev, A_BOOL ASyncMode); -A_STATUS DevEnableRecv(AR6K_DEVICE *pDev, A_BOOL ASyncMode); -A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev); -A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev); -A_STATUS DevWaitForPendingRecv(AR6K_DEVICE *pDev,A_UINT32 TimeoutInMs,A_BOOL *pbIsRecvPending); +int DevRWCompletionHandler(void *context, int status); +int DevDsrHandler(void *context); +int DevCheckPendingRecvMsgsAsync(void *context); +void DevAsyncIrqProcessComplete(struct ar6k_device *pDev); +void DevDumpRegisters(struct ar6k_device *pDev, + struct ar6k_irq_proc_registers *pIrqProcRegs, + struct ar6k_irq_enable_registers *pIrqEnableRegs); + +#define DEV_STOP_RECV_ASYNC true +#define DEV_STOP_RECV_SYNC false +#define DEV_ENABLE_RECV_ASYNC true +#define DEV_ENABLE_RECV_SYNC false +int DevStopRecv(struct ar6k_device *pDev, bool ASyncMode); +int DevEnableRecv(struct ar6k_device *pDev, bool ASyncMode); +int DevEnableInterrupts(struct ar6k_device *pDev); +int DevDisableInterrupts(struct ar6k_device *pDev); +int DevWaitForPendingRecv(struct ar6k_device *pDev,u32 TimeoutInMs,bool *pbIsRecvPending); #define DEV_CALC_RECV_PADDED_LEN(pDev, length) (((length) + (pDev)->BlockMask) & (~((pDev)->BlockMask))) #define DEV_CALC_SEND_PADDED_LEN(pDev, length) DEV_CALC_RECV_PADDED_LEN(pDev,length) #define DEV_IS_LEN_BLOCK_ALIGNED(pDev, length) (((length) % (pDev)->BlockSize) == 0) -static INLINE A_STATUS DevSendPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 SendLength) { - A_UINT32 paddedLength; - A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE; - A_STATUS status; +static INLINE int DevSendPacket(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 SendLength) { + u32 paddedLength; + bool sync = (pPacket->Completion == NULL) ? true : false; + int status; /* adjust the length to be a multiple of block size if appropriate */ paddedLength = DEV_CALC_SEND_PADDED_LEN(pDev, SendLength); #if 0 if (paddedLength > pPacket->BufferLength) { - A_ASSERT(FALSE); + A_ASSERT(false); if (pPacket->Completion != NULL) { COMPLETE_HTC_PACKET(pPacket,A_EINVAL); - return A_OK; + return 0; } return A_EINVAL; } @@ -212,29 +212,29 @@ static INLINE A_STATUS DevSendPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_U pPacket->Status = status; } else { if (status == A_PENDING) { - status = A_OK; + status = 0; } } return status; } -static INLINE A_STATUS DevRecvPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 RecvLength) { - A_UINT32 paddedLength; - A_STATUS status; - A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE; +static INLINE int DevRecvPacket(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 RecvLength) { + u32 paddedLength; + int status; + bool sync = (pPacket->Completion == NULL) ? true : false; /* adjust the length to be a multiple of block size if appropriate */ paddedLength = DEV_CALC_RECV_PADDED_LEN(pDev, RecvLength); if (paddedLength > pPacket->BufferLength) { - A_ASSERT(FALSE); + A_ASSERT(false); AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DevRecvPacket, Not enough space for padlen:%d recvlen:%d bufferlen:%d \n", paddedLength,RecvLength,pPacket->BufferLength)); if (pPacket->Completion != NULL) { COMPLETE_HTC_PACKET(pPacket,A_EINVAL); - return A_OK; + return 0; } return A_EINVAL; } @@ -272,27 +272,33 @@ static INLINE A_STATUS DevRecvPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_U * */ -A_STATUS DevCopyScatterListToFromDMABuffer(HIF_SCATTER_REQ *pReq, A_BOOL FromDMA); +int DevCopyScatterListToFromDMABuffer(struct hif_scatter_req *pReq, bool FromDMA); /* copy any READ data back into scatter list */ -#define DEV_FINISH_SCATTER_OPERATION(pR) \ - if (A_SUCCESS((pR)->CompletionStatus) && \ - !((pR)->Request & HIF_WRITE) && \ - ((pR)->ScatterMethod == HIF_SCATTER_DMA_BOUNCE)) { \ - (pR)->CompletionStatus = DevCopyScatterListToFromDMABuffer((pR),FROM_DMA_BUFFER); \ - } +#define DEV_FINISH_SCATTER_OPERATION(pR) \ +do { \ + if (!((pR)->CompletionStatus) && \ + !((pR)->Request & HIF_WRITE) && \ + ((pR)->ScatterMethod == HIF_SCATTER_DMA_BOUNCE)) { \ + (pR)->CompletionStatus = \ + DevCopyScatterListToFromDMABuffer((pR), \ + FROM_DMA_BUFFER); \ + } \ +} while (0) /* copy any WRITE data to bounce buffer */ -static INLINE A_STATUS DEV_PREPARE_SCATTER_OPERATION(HIF_SCATTER_REQ *pReq) { +static INLINE int DEV_PREPARE_SCATTER_OPERATION(struct hif_scatter_req *pReq) { if ((pReq->Request & HIF_WRITE) && (pReq->ScatterMethod == HIF_SCATTER_DMA_BOUNCE)) { return DevCopyScatterListToFromDMABuffer(pReq,TO_DMA_BUFFER); } else { - return A_OK; + return 0; } } -A_STATUS DevSetupMsgBundling(AR6K_DEVICE *pDev, int MaxMsgsPerTransfer); +int DevSetupMsgBundling(struct ar6k_device *pDev, int MaxMsgsPerTransfer); + +int DevCleanupMsgBundling(struct ar6k_device *pDev); #define DEV_GET_MAX_MSG_PER_BUNDLE(pDev) (pDev)->HifScatterInfo.MaxScatterEntries #define DEV_GET_MAX_BUNDLE_LENGTH(pDev) (pDev)->HifScatterInfo.MaxTransferSizePerScatterReq @@ -305,25 +311,25 @@ A_STATUS DevSetupMsgBundling(AR6K_DEVICE *pDev, int MaxMsgsPerTransfer); #define DEV_GET_MAX_BUNDLE_RECV_LENGTH(pDev) (pDev)->MaxRecvBundleSize #define DEV_GET_MAX_BUNDLE_SEND_LENGTH(pDev) (pDev)->MaxSendBundleSize -#define DEV_SCATTER_READ TRUE -#define DEV_SCATTER_WRITE FALSE -#define DEV_SCATTER_ASYNC TRUE -#define DEV_SCATTER_SYNC FALSE -A_STATUS DevSubmitScatterRequest(AR6K_DEVICE *pDev, HIF_SCATTER_REQ *pScatterReq, A_BOOL Read, A_BOOL Async); +#define DEV_SCATTER_READ true +#define DEV_SCATTER_WRITE false +#define DEV_SCATTER_ASYNC true +#define DEV_SCATTER_SYNC false +int DevSubmitScatterRequest(struct ar6k_device *pDev, struct hif_scatter_req *pScatterReq, bool Read, bool Async); #ifdef MBOXHW_UNIT_TEST -A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev); +int DoMboxHWTest(struct ar6k_device *pDev); #endif /* completely virtual */ -typedef struct _DEV_SCATTER_DMA_VIRTUAL_INFO { - A_UINT8 *pVirtDmaBuffer; /* dma-able buffer - CPU accessible address */ - A_UINT8 DataArea[1]; /* start of data area */ -} DEV_SCATTER_DMA_VIRTUAL_INFO; +struct dev_scatter_dma_virtual_info { + u8 *pVirtDmaBuffer; /* dma-able buffer - CPU accessible address */ + u8 DataArea[1]; /* start of data area */ +}; -void DumpAR6KDevState(AR6K_DEVICE *pDev); +void DumpAR6KDevState(struct ar6k_device *pDev); /**************************************************/ /****** GMBOX functions and definitions @@ -333,21 +339,21 @@ void DumpAR6KDevState(AR6K_DEVICE *pDev); #ifdef ATH_AR6K_ENABLE_GMBOX -void DevCleanupGMbox(AR6K_DEVICE *pDev); -A_STATUS DevSetupGMbox(AR6K_DEVICE *pDev); -A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev); -void DevNotifyGMboxTargetFailure(AR6K_DEVICE *pDev); +void DevCleanupGMbox(struct ar6k_device *pDev); +int DevSetupGMbox(struct ar6k_device *pDev); +int DevCheckGMboxInterrupts(struct ar6k_device *pDev); +void DevNotifyGMboxTargetFailure(struct ar6k_device *pDev); #else /* compiled out */ #define DevCleanupGMbox(p) -#define DevCheckGMboxInterrupts(p) A_OK +#define DevCheckGMboxInterrupts(p) 0 #define DevNotifyGMboxTargetFailure(p) -static INLINE A_STATUS DevSetupGMbox(AR6K_DEVICE *pDev) { - pDev->GMboxEnabled = FALSE; - return A_OK; +static INLINE int DevSetupGMbox(struct ar6k_device *pDev) { + pDev->GMboxEnabled = false; + return 0; } #endif @@ -355,12 +361,12 @@ static INLINE A_STATUS DevSetupGMbox(AR6K_DEVICE *pDev) { #ifdef ATH_AR6K_ENABLE_GMBOX /* GMBOX protocol modules must expose each of these internal APIs */ -HCI_TRANSPORT_HANDLE GMboxAttachProtocol(AR6K_DEVICE *pDev, HCI_TRANSPORT_CONFIG_INFO *pInfo); -A_STATUS GMboxProtocolInstall(AR6K_DEVICE *pDev); -void GMboxProtocolUninstall(AR6K_DEVICE *pDev); +HCI_TRANSPORT_HANDLE GMboxAttachProtocol(struct ar6k_device *pDev, struct hci_transport_config_info *pInfo); +int GMboxProtocolInstall(struct ar6k_device *pDev); +void GMboxProtocolUninstall(struct ar6k_device *pDev); /* API used by GMBOX protocol modules */ -AR6K_DEVICE *HTCGetAR6KDevice(void *HTCHandle); +struct ar6k_device *HTCGetAR6KDevice(void *HTCHandle); #define DEV_GMBOX_SET_PROTOCOL(pDev,recv_callback,credits_pending,failure,statedump,context) \ { \ (pDev)->GMboxInfo.pProtocolContext = (context); \ @@ -372,11 +378,11 @@ AR6K_DEVICE *HTCGetAR6KDevice(void *HTCHandle); #define DEV_GMBOX_GET_PROTOCOL(pDev) (pDev)->GMboxInfo.pProtocolContext -A_STATUS DevGMboxWrite(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 WriteLength); -A_STATUS DevGMboxRead(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 ReadLength); +int DevGMboxWrite(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 WriteLength); +int DevGMboxRead(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 ReadLength); -#define PROC_IO_ASYNC TRUE -#define PROC_IO_SYNC FALSE +#define PROC_IO_ASYNC true +#define PROC_IO_SYNC false typedef enum GMBOX_IRQ_ACTION_TYPE { GMBOX_ACTION_NONE = 0, GMBOX_DISABLE_ALL, @@ -387,11 +393,11 @@ typedef enum GMBOX_IRQ_ACTION_TYPE { GMBOX_CREDIT_IRQ_DISABLE, } GMBOX_IRQ_ACTION_TYPE; -A_STATUS DevGMboxIRQAction(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE, A_BOOL AsyncMode); -A_STATUS DevGMboxReadCreditCounter(AR6K_DEVICE *pDev, A_BOOL AsyncMode, int *pCredits); -A_STATUS DevGMboxReadCreditSize(AR6K_DEVICE *pDev, int *pCreditSize); -A_STATUS DevGMboxRecvLookAheadPeek(AR6K_DEVICE *pDev, A_UINT8 *pLookAheadBuffer, int *pLookAheadBytes); -A_STATUS DevGMboxSetTargetInterrupt(AR6K_DEVICE *pDev, int SignalNumber, int AckTimeoutMS); +int DevGMboxIRQAction(struct ar6k_device *pDev, GMBOX_IRQ_ACTION_TYPE, bool AsyncMode); +int DevGMboxReadCreditCounter(struct ar6k_device *pDev, bool AsyncMode, int *pCredits); +int DevGMboxReadCreditSize(struct ar6k_device *pDev, int *pCreditSize); +int DevGMboxRecvLookAheadPeek(struct ar6k_device *pDev, u8 *pLookAheadBuffer, int *pLookAheadBytes); +int DevGMboxSetTargetInterrupt(struct ar6k_device *pDev, int SignalNumber, int AckTimeoutMS); #endif diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c index 920123b..5e6d1e0 100644 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c +++ b/drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c @@ -33,17 +33,17 @@ #include "htc_packet.h" #include "ar6k.h" -extern void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket); -extern HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev); +extern void AR6KFreeIOPacket(struct ar6k_device *pDev, struct htc_packet *pPacket); +extern struct htc_packet *AR6KAllocIOPacket(struct ar6k_device *pDev); -static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev); +static int DevServiceDebugInterrupt(struct ar6k_device *pDev); #define DELAY_PER_INTERVAL_MS 10 /* 10 MS delay per polling interval */ /* completion routine for ALL HIF layer async I/O */ -A_STATUS DevRWCompletionHandler(void *context, A_STATUS status) +int DevRWCompletionHandler(void *context, int status) { - HTC_PACKET *pPacket = (HTC_PACKET *)context; + struct htc_packet *pPacket = (struct htc_packet *)context; AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+DevRWCompletionHandler (Pkt:0x%lX) , Status: %d \n", @@ -55,26 +55,26 @@ A_STATUS DevRWCompletionHandler(void *context, A_STATUS status) AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-DevRWCompletionHandler\n")); - return A_OK; + return 0; } /* mailbox recv message polling */ -A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev, - A_UINT32 *pLookAhead, +int DevPollMboxMsgRecv(struct ar6k_device *pDev, + u32 *pLookAhead, int TimeoutMS) { - A_STATUS status = A_OK; + int status = 0; int timeout = TimeoutMS/DELAY_PER_INTERVAL_MS; A_ASSERT(timeout > 0); AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+DevPollMboxMsgRecv \n")); - while (TRUE) { + while (true) { if (pDev->GetPendingEventsFunc != NULL) { - HIF_PENDING_EVENTS_INFO events; + struct hif_pending_events_info events; #ifdef THREAD_X events.Polling =1; @@ -85,7 +85,7 @@ A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev, status = pDev->GetPendingEventsFunc(pDev->HIFDevice, &events, NULL); - if (A_FAILED(status)) + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to get pending events \n")); break; @@ -104,12 +104,12 @@ A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev, /* load the register table */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, - (A_UINT8 *)&pDev->IrqProcRegisters, + (u8 *)&pDev->IrqProcRegisters, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); - if (A_FAILED(status)){ + if (status){ AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to read register table \n")); break; } @@ -152,11 +152,11 @@ A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev, return status; } -static A_STATUS DevServiceCPUInterrupt(AR6K_DEVICE *pDev) +static int DevServiceCPUInterrupt(struct ar6k_device *pDev) { - A_STATUS status; - A_UINT8 cpu_int_status; - A_UINT8 regBuffer[4]; + int status; + u8 cpu_int_status; + u8 regBuffer[4]; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("CPU Interrupt\n")); cpu_int_status = pDev->IrqProcRegisters.cpu_int_status & @@ -187,16 +187,16 @@ static A_STATUS DevServiceCPUInterrupt(AR6K_DEVICE *pDev) HIF_WR_SYNC_BYTE_FIX, NULL); - A_ASSERT(status == A_OK); + A_ASSERT(status == 0); return status; } -static A_STATUS DevServiceErrorInterrupt(AR6K_DEVICE *pDev) +static int DevServiceErrorInterrupt(struct ar6k_device *pDev) { - A_STATUS status; - A_UINT8 error_int_status; - A_UINT8 regBuffer[4]; + int status; + u8 error_int_status; + u8 regBuffer[4]; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Error Interrupt\n")); error_int_status = pDev->IrqProcRegisters.error_int_status & 0x0F; @@ -241,14 +241,14 @@ static A_STATUS DevServiceErrorInterrupt(AR6K_DEVICE *pDev) HIF_WR_SYNC_BYTE_FIX, NULL); - A_ASSERT(status == A_OK); + A_ASSERT(status == 0); return status; } -static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev) +static int DevServiceDebugInterrupt(struct ar6k_device *pDev) { - A_UINT32 dummy; - A_STATUS status; + u32 dummy; + int status; /* Send a target failure event to the application */ AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Target debug interrupt\n")); @@ -266,18 +266,18 @@ static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev) /* read counter to clear interrupt */ status = HIFReadWrite(pDev->HIFDevice, COUNT_DEC_ADDRESS, - (A_UINT8 *)&dummy, + (u8 *)&dummy, 4, HIF_RD_SYNC_BYTE_INC, NULL); - A_ASSERT(status == A_OK); + A_ASSERT(status == 0); return status; } -static A_STATUS DevServiceCounterInterrupt(AR6K_DEVICE *pDev) +static int DevServiceCounterInterrupt(struct ar6k_device *pDev) { - A_UINT8 counter_int_status; + u8 counter_int_status; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Counter Interrupt\n")); @@ -296,21 +296,21 @@ static A_STATUS DevServiceCounterInterrupt(AR6K_DEVICE *pDev) return DevServiceDebugInterrupt(pDev); } - return A_OK; + return 0; } /* callback when our fetch to get interrupt status registers completes */ -static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) +static void DevGetEventAsyncHandler(void *Context, struct htc_packet *pPacket) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; - A_UINT32 lookAhead = 0; - A_BOOL otherInts = FALSE; + struct ar6k_device *pDev = (struct ar6k_device *)Context; + u32 lookAhead = 0; + bool otherInts = false; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGetEventAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); do { - if (A_FAILED(pPacket->Status)) { + if (pPacket->Status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" GetEvents I/O request failed, status:%d \n", pPacket->Status)); /* bail out, don't unmask HIF interrupt */ @@ -319,7 +319,7 @@ static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) if (pDev->GetPendingEventsFunc != NULL) { /* the HIF layer collected the information for us */ - HIF_PENDING_EVENTS_INFO *pEvents = (HIF_PENDING_EVENTS_INFO *)pPacket->pBuffer; + struct hif_pending_events_info *pEvents = (struct hif_pending_events_info *)pPacket->pBuffer; if (pEvents->Events & HIF_RECV_MSG_AVAIL) { lookAhead = pEvents->LookAhead; if (0 == lookAhead) { @@ -327,12 +327,12 @@ static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) } } if (pEvents->Events & HIF_OTHER_EVENTS) { - otherInts = TRUE; + otherInts = true; } } else { /* standard interrupt table handling.... */ - AR6K_IRQ_PROC_REGISTERS *pReg = (AR6K_IRQ_PROC_REGISTERS *)pPacket->pBuffer; - A_UINT8 host_int_status; + struct ar6k_irq_proc_registers *pReg = (struct ar6k_irq_proc_registers *)pPacket->pBuffer; + u8 host_int_status; host_int_status = pReg->host_int_status & pDev->IrqEnableRegisters.int_status_enable; @@ -349,7 +349,7 @@ static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) if (host_int_status) { /* there are other interrupts to handle */ - otherInts = TRUE; + otherInts = true; } } @@ -363,7 +363,7 @@ static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) HIFAckInterrupt(pDev->HIFDevice); } else { int fetched = 0; - A_STATUS status; + int status; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, (" DevGetEventAsyncHandler : detected another message, lookahead :0x%X \n", @@ -372,14 +372,14 @@ static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) * go get the next message */ status = pDev->MessagePendingCallback(pDev->HTCContext, &lookAhead, 1, NULL, &fetched); - if (A_SUCCESS(status) && !fetched) { + if (!status && !fetched) { /* HTC layer could not pull out messages due to lack of resources, stop IRQ processing */ AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("MessagePendingCallback did not pull any messages, force-ack \n")); DevAsyncIrqProcessComplete(pDev); } } - } while (FALSE); + } while (false); /* free this IO packet */ AR6KFreeIOPacket(pDev,pPacket); @@ -388,11 +388,11 @@ static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket) /* called by the HTC layer when it wants us to check if the device has any more pending * recv messages, this starts off a series of async requests to read interrupt registers */ -A_STATUS DevCheckPendingRecvMsgsAsync(void *context) +int DevCheckPendingRecvMsgsAsync(void *context) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)context; - A_STATUS status = A_OK; - HTC_PACKET *pIOPacket; + struct ar6k_device *pDev = (struct ar6k_device *)context; + int status = 0; + struct htc_packet *pIOPacket; /* this is called in an ASYNC only context, we may NOT block, sleep or call any apis that can * cause us to switch contexts */ @@ -428,7 +428,7 @@ A_STATUS DevCheckPendingRecvMsgsAsync(void *context) /* there should be only 1 asynchronous request out at a time to read these registers * so this should actually never happen */ status = A_NO_MEMORY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -439,7 +439,7 @@ A_STATUS DevCheckPendingRecvMsgsAsync(void *context) if (pDev->GetPendingEventsFunc) { /* HIF layer has it's own mechanism, pass the IO to it.. */ status = pDev->GetPendingEventsFunc(pDev->HIFDevice, - (HIF_PENDING_EVENTS_INFO *)pIOPacket->pBuffer, + (struct hif_pending_events_info *)pIOPacket->pBuffer, pIOPacket); } else { @@ -453,25 +453,25 @@ A_STATUS DevCheckPendingRecvMsgsAsync(void *context) } AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Async IO issued to get interrupt status...\n")); - } while (FALSE); + } while (false); AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevCheckPendingRecvMsgsAsync \n")); return status; } -void DevAsyncIrqProcessComplete(AR6K_DEVICE *pDev) +void DevAsyncIrqProcessComplete(struct ar6k_device *pDev) { AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("DevAsyncIrqProcessComplete - forcing HIF IRQ ACK \n")); HIFAckInterrupt(pDev->HIFDevice); } /* process pending interrupts synchronously */ -static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pASyncProcessing) +static int ProcessPendingIRQs(struct ar6k_device *pDev, bool *pDone, bool *pASyncProcessing) { - A_STATUS status = A_OK; - A_UINT8 host_int_status = 0; - A_UINT32 lookAhead = 0; + int status = 0; + u8 host_int_status = 0; + u32 lookAhead = 0; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+ProcessPendingIRQs: (dev: 0x%lX)\n", (unsigned long)pDev)); @@ -490,7 +490,7 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS } if (pDev->GetPendingEventsFunc != NULL) { - HIF_PENDING_EVENTS_INFO events; + struct hif_pending_events_info events; #ifdef THREAD_X events.Polling= 0; @@ -501,7 +501,7 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS &events, NULL); - if (A_FAILED(status)) { + if (status) { break; } @@ -545,12 +545,12 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS #endif /* CONFIG_MMC_SDHCI_S3C */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, - (A_UINT8 *)&pDev->IrqProcRegisters, + (u8 *)&pDev->IrqProcRegisters, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); - if (A_FAILED(status)) { + if (status) { break; } @@ -591,19 +591,19 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS status = DevCheckGMboxInterrupts(pDev); } - } while (FALSE); + } while (false); do { /* did the interrupt status fetches succeed? */ - if (A_FAILED(status)) { + if (status) { break; } if ((0 == host_int_status) && (0 == lookAhead)) { /* nothing to process, the caller can use this to break out of a loop */ - *pDone = TRUE; + *pDone = true; break; } @@ -617,14 +617,14 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS * completion routine of the callers read request. This can improve performance * by reducing context switching when we rapidly pull packets */ status = pDev->MessagePendingCallback(pDev->HTCContext, &lookAhead, 1, pASyncProcessing, &fetched); - if (A_FAILED(status)) { + if (status) { break; } if (!fetched) { /* HTC could not pull any messages out due to lack of resources */ /* force DSR handler to ack the interrupt */ - *pASyncProcessing = FALSE; + *pASyncProcessing = false; pDev->RecheckIRQStatusCnt = 0; } } @@ -637,7 +637,7 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS if (HOST_INT_STATUS_CPU_GET(host_int_status)) { /* CPU Interrupt */ status = DevServiceCPUInterrupt(pDev); - if (A_FAILED(status)){ + if (status){ break; } } @@ -645,7 +645,7 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS if (HOST_INT_STATUS_ERROR_GET(host_int_status)) { /* Error Interrupt */ status = DevServiceErrorInterrupt(pDev); - if (A_FAILED(status)){ + if (status){ break; } } @@ -653,12 +653,12 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS if (HOST_INT_STATUS_COUNTER_GET(host_int_status)) { /* Counter Interrupt */ status = DevServiceCounterInterrupt(pDev); - if (A_FAILED(status)){ + if (status){ break; } } - } while (FALSE); + } while (false); /* an optimization to bypass reading the IRQ status registers unecessarily which can re-wake * the target, if upper layers determine that we are in a low-throughput mode, we can @@ -670,7 +670,7 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS * messages from the mailbox before exiting the ISR routine. */ if (!(*pASyncProcessing) && (pDev->RecheckIRQStatusCnt == 0) && (pDev->GetPendingEventsFunc == NULL)) { AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("Bypassing IRQ Status re-check, forcing done \n")); - *pDone = TRUE; + *pDone = true; } AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-ProcessPendingIRQs: (done:%d, async:%d) status=%d \n", @@ -681,12 +681,12 @@ static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pAS /* Synchronousinterrupt handler, this handler kicks off all interrupt processing.*/ -A_STATUS DevDsrHandler(void *context) +int DevDsrHandler(void *context) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)context; - A_STATUS status = A_OK; - A_BOOL done = FALSE; - A_BOOL asyncProc = FALSE; + struct ar6k_device *pDev = (struct ar6k_device *)context; + int status = 0; + bool done = false; + bool asyncProc = false; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDsrHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); @@ -697,13 +697,13 @@ A_STATUS DevDsrHandler(void *context) while (!done) { status = ProcessPendingIRQs(pDev, &done, &asyncProc); - if (A_FAILED(status)) { + if (status) { break; } if (HIF_DEVICE_IRQ_SYNC_ONLY == pDev->HifIRQProcessingMode) { /* the HIF layer does not allow async IRQ processing, override the asyncProc flag */ - asyncProc = FALSE; + asyncProc = false; /* this will cause us to re-enter ProcessPendingIRQ() and re-read interrupt status registers. * this has a nice side effect of blocking us until all async read requests are completed. * This behavior is required on some HIF implementations that do not allow ASYNC @@ -725,7 +725,7 @@ A_STATUS DevDsrHandler(void *context) } - if (A_SUCCESS(status) && !asyncProc) { + if (!status && !asyncProc) { /* Ack the interrupt only if : * 1. we did not get any errors in processing interrupts * 2. there are no outstanding async processing requests */ @@ -744,26 +744,26 @@ A_STATUS DevDsrHandler(void *context) } #ifdef ATH_DEBUG_MODULE -void DumpAR6KDevState(AR6K_DEVICE *pDev) +void DumpAR6KDevState(struct ar6k_device *pDev) { - A_STATUS status; - AR6K_IRQ_ENABLE_REGISTERS regs; - AR6K_IRQ_PROC_REGISTERS procRegs; + int status; + struct ar6k_irq_enable_registers regs; + struct ar6k_irq_proc_registers procRegs; LOCK_AR6K(pDev); /* copy into our temp area */ - A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); /* load the register table from the device */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, - (A_UINT8 *)&procRegs, + (u8 *)&procRegs, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DumpAR6KDevState : Failed to read register table (%d) \n",status)); return; diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c index e3d270d..3740011 100644 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c +++ b/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c @@ -54,18 +54,18 @@ /* external APIs for allocating and freeing internal I/O packets to handle ASYNC I/O */ -extern void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket); -extern HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev); +extern void AR6KFreeIOPacket(struct ar6k_device *pDev, struct htc_packet *pPacket); +extern struct htc_packet *AR6KAllocIOPacket(struct ar6k_device *pDev); /* callback when our fetch to enable/disable completes */ -static void DevGMboxIRQActionAsyncHandler(void *Context, HTC_PACKET *pPacket) +static void DevGMboxIRQActionAsyncHandler(void *Context, struct htc_packet *pPacket) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; + struct ar6k_device *pDev = (struct ar6k_device *)Context; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGMboxIRQActionAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - if (A_FAILED(pPacket->Status)) { + if (pPacket->Status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("IRQAction Operation (%d) failed! status:%d \n", pPacket->PktInfo.AsRx.HTCRxFlags,pPacket->Status)); } @@ -74,26 +74,26 @@ static void DevGMboxIRQActionAsyncHandler(void *Context, HTC_PACKET *pPacket) AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGMboxIRQActionAsyncHandler \n")); } -static A_STATUS DevGMboxCounterEnableDisable(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, A_BOOL AsyncMode) +static int DevGMboxCounterEnableDisable(struct ar6k_device *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, bool AsyncMode) { - A_STATUS status = A_OK; - AR6K_IRQ_ENABLE_REGISTERS regs; - HTC_PACKET *pIOPacket = NULL; + int status = 0; + struct ar6k_irq_enable_registers regs; + struct htc_packet *pIOPacket = NULL; LOCK_AR6K(pDev); if (GMBOX_CREDIT_IRQ_ENABLE == IrqAction) { - pDev->GMboxInfo.CreditCountIRQEnabled = TRUE; + pDev->GMboxInfo.CreditCountIRQEnabled = true; pDev->IrqEnableRegisters.counter_int_status_enable |= COUNTER_INT_STATUS_ENABLE_BIT_SET(1 << AR6K_GMBOX_CREDIT_COUNTER); pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_COUNTER_SET(0x01); } else { - pDev->GMboxInfo.CreditCountIRQEnabled = FALSE; + pDev->GMboxInfo.CreditCountIRQEnabled = false; pDev->IrqEnableRegisters.counter_int_status_enable &= ~(COUNTER_INT_STATUS_ENABLE_BIT_SET(1 << AR6K_GMBOX_CREDIT_COUNTER)); } /* copy into our temp area */ - A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); @@ -105,12 +105,12 @@ static A_STATUS DevGMboxCounterEnableDisable(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION if (NULL == pIOPacket) { status = A_NO_MEMORY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } /* copy values to write to our async I/O buffer */ - A_MEMCPY(pIOPacket->pBuffer,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); + memcpy(pIOPacket->pBuffer,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); /* stick in our completion routine when the I/O operation completes */ pIOPacket->Completion = DevGMboxIRQActionAsyncHandler; @@ -135,9 +135,9 @@ static A_STATUS DevGMboxCounterEnableDisable(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION AR6K_IRQ_ENABLE_REGS_SIZE, HIF_WR_SYNC_BYTE_INC, NULL); - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" IRQAction Operation (%d) failed! status:%d \n", IrqAction, status)); } else { @@ -155,11 +155,11 @@ static A_STATUS DevGMboxCounterEnableDisable(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION } -A_STATUS DevGMboxIRQAction(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, A_BOOL AsyncMode) +int DevGMboxIRQAction(struct ar6k_device *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, bool AsyncMode) { - A_STATUS status = A_OK; - HTC_PACKET *pIOPacket = NULL; - A_UINT8 GMboxIntControl[4]; + int status = 0; + struct htc_packet *pIOPacket = NULL; + u8 GMboxIntControl[4]; if (GMBOX_CREDIT_IRQ_ENABLE == IrqAction) { return DevGMboxCounterEnableDisable(pDev, GMBOX_CREDIT_IRQ_ENABLE, AsyncMode); @@ -192,7 +192,7 @@ A_STATUS DevGMboxIRQAction(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, A break; case GMBOX_ACTION_NONE: default: - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -211,12 +211,12 @@ A_STATUS DevGMboxIRQAction(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, A if (NULL == pIOPacket) { status = A_NO_MEMORY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } /* copy values to write to our async I/O buffer */ - A_MEMCPY(pIOPacket->pBuffer,GMboxIntControl,sizeof(GMboxIntControl)); + memcpy(pIOPacket->pBuffer,GMboxIntControl,sizeof(GMboxIntControl)); /* stick in our completion routine when the I/O operation completes */ pIOPacket->Completion = DevGMboxIRQActionAsyncHandler; @@ -242,9 +242,9 @@ A_STATUS DevGMboxIRQAction(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, A HIF_WR_SYNC_BYTE_FIX, NULL); - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" IRQAction Operation (%d) failed! status:%d \n", IrqAction, status)); } else { @@ -261,18 +261,18 @@ A_STATUS DevGMboxIRQAction(AR6K_DEVICE *pDev, GMBOX_IRQ_ACTION_TYPE IrqAction, A return status; } -void DevCleanupGMbox(AR6K_DEVICE *pDev) +void DevCleanupGMbox(struct ar6k_device *pDev) { if (pDev->GMboxEnabled) { - pDev->GMboxEnabled = FALSE; + pDev->GMboxEnabled = false; GMboxProtocolUninstall(pDev); } } -A_STATUS DevSetupGMbox(AR6K_DEVICE *pDev) +int DevSetupGMbox(struct ar6k_device *pDev) { - A_STATUS status = A_OK; - A_UINT8 muxControl[4]; + int status = 0; + u8 muxControl[4]; do { @@ -285,7 +285,7 @@ A_STATUS DevSetupGMbox(AR6K_DEVICE *pDev) status = DevGMboxIRQAction(pDev, GMBOX_DISABLE_ALL, PROC_IO_SYNC); - if (A_FAILED(status)) { + if (status) { break; } @@ -305,29 +305,29 @@ A_STATUS DevSetupGMbox(AR6K_DEVICE *pDev) HIF_WR_SYNC_BYTE_FIX, /* hit this register 4 times */ NULL); - if (A_FAILED(status)) { + if (status) { break; } status = GMboxProtocolInstall(pDev); - if (A_FAILED(status)) { + if (status) { break; } - pDev->GMboxEnabled = TRUE; + pDev->GMboxEnabled = true; - } while (FALSE); + } while (false); return status; } -A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev) +int DevCheckGMboxInterrupts(struct ar6k_device *pDev) { - A_STATUS status = A_OK; - A_UINT8 counter_int_status; + int status = 0; + u8 counter_int_status; int credits; - A_UINT8 host_int_status2; + u8 host_int_status2; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("+DevCheckGMboxInterrupts \n")); @@ -348,7 +348,7 @@ A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev) status = A_ECOMM; } - if (A_FAILED(status)) { + if (status) { if (pDev->GMboxInfo.pTargetFailureCallback != NULL) { pDev->GMboxInfo.pTargetFailureCallback(pDev->GMboxInfo.pProtocolContext, status); } @@ -360,12 +360,12 @@ A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev) A_ASSERT(pDev->GMboxInfo.pMessagePendingCallBack != NULL); status = pDev->GMboxInfo.pMessagePendingCallBack( pDev->GMboxInfo.pProtocolContext, - (A_UINT8 *)&pDev->IrqProcRegisters.rx_gmbox_lookahead_alias[0], + (u8 *)&pDev->IrqProcRegisters.rx_gmbox_lookahead_alias[0], pDev->IrqProcRegisters.gmbox_rx_avail); } } - if (A_FAILED(status)) { + if (status) { break; } @@ -378,7 +378,7 @@ A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev) /* do synchronous read */ status = DevGMboxReadCreditCounter(pDev, PROC_IO_SYNC, &credits); - if (A_FAILED(status)) { + if (status) { break; } @@ -388,7 +388,7 @@ A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev) pDev->GMboxInfo.CreditCountIRQEnabled); } - } while (FALSE); + } while (false); AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("-DevCheckGMboxInterrupts (%d) \n",status)); @@ -396,12 +396,12 @@ A_STATUS DevCheckGMboxInterrupts(AR6K_DEVICE *pDev) } -A_STATUS DevGMboxWrite(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 WriteLength) +int DevGMboxWrite(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 WriteLength) { - A_UINT32 paddedLength; - A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE; - A_STATUS status; - A_UINT32 address; + u32 paddedLength; + bool sync = (pPacket->Completion == NULL) ? true : false; + int status; + u32 address; /* adjust the length to be a multiple of block size if appropriate */ paddedLength = DEV_CALC_SEND_PADDED_LEN(pDev, WriteLength); @@ -426,31 +426,31 @@ A_STATUS DevGMboxWrite(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 WriteLen pPacket->Status = status; } else { if (status == A_PENDING) { - status = A_OK; + status = 0; } } return status; } -A_STATUS DevGMboxRead(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 ReadLength) +int DevGMboxRead(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 ReadLength) { - A_UINT32 paddedLength; - A_STATUS status; - A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE; + u32 paddedLength; + int status; + bool sync = (pPacket->Completion == NULL) ? true : false; /* adjust the length to be a multiple of block size if appropriate */ paddedLength = DEV_CALC_RECV_PADDED_LEN(pDev, ReadLength); if (paddedLength > pPacket->BufferLength) { - A_ASSERT(FALSE); + A_ASSERT(false); AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DevGMboxRead, Not enough space for padlen:%d recvlen:%d bufferlen:%d \n", paddedLength,ReadLength,pPacket->BufferLength)); if (pPacket->Completion != NULL) { COMPLETE_HTC_PACKET(pPacket,A_EINVAL); - return A_OK; + return 0; } return A_EINVAL; } @@ -477,7 +477,7 @@ A_STATUS DevGMboxRead(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 ReadLengt } -static int ProcessCreditCounterReadBuffer(A_UINT8 *pBuffer, int Length) +static int ProcessCreditCounterReadBuffer(u8 *pBuffer, int Length) { int credits = 0; @@ -516,13 +516,13 @@ static int ProcessCreditCounterReadBuffer(A_UINT8 *pBuffer, int Length) /* callback when our fetch to enable/disable completes */ -static void DevGMboxReadCreditsAsyncHandler(void *Context, HTC_PACKET *pPacket) +static void DevGMboxReadCreditsAsyncHandler(void *Context, struct htc_packet *pPacket) { - AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context; + struct ar6k_device *pDev = (struct ar6k_device *)Context; AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGMboxReadCreditsAsyncHandler: (dev: 0x%lX)\n", (unsigned long)pDev)); - if (A_FAILED(pPacket->Status)) { + if (pPacket->Status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Read Credit Operation failed! status:%d \n", pPacket->Status)); } else { @@ -539,10 +539,10 @@ static void DevGMboxReadCreditsAsyncHandler(void *Context, HTC_PACKET *pPacket) AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGMboxReadCreditsAsyncHandler \n")); } -A_STATUS DevGMboxReadCreditCounter(AR6K_DEVICE *pDev, A_BOOL AsyncMode, int *pCredits) +int DevGMboxReadCreditCounter(struct ar6k_device *pDev, bool AsyncMode, int *pCredits) { - A_STATUS status = A_OK; - HTC_PACKET *pIOPacket = NULL; + int status = 0; + struct htc_packet *pIOPacket = NULL; AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+DevGMboxReadCreditCounter (%s) \n", AsyncMode ? "ASYNC" : "SYNC")); @@ -552,7 +552,7 @@ A_STATUS DevGMboxReadCreditCounter(AR6K_DEVICE *pDev, A_BOOL AsyncMode, int *pCr if (NULL == pIOPacket) { status = A_NO_MEMORY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -581,15 +581,15 @@ A_STATUS DevGMboxReadCreditCounter(AR6K_DEVICE *pDev, A_BOOL AsyncMode, int *pCr AR6K_REG_IO_BUFFER_SIZE, HIF_RD_SYNC_BYTE_FIX, NULL); - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" DevGMboxReadCreditCounter failed! status:%d \n", status)); } if (pIOPacket != NULL) { - if (A_SUCCESS(status)) { + if (!status) { /* sync mode processing */ *pCredits = ProcessCreditCounterReadBuffer(pIOPacket->pBuffer, AR6K_REG_IO_BUFFER_SIZE); } @@ -602,10 +602,10 @@ A_STATUS DevGMboxReadCreditCounter(AR6K_DEVICE *pDev, A_BOOL AsyncMode, int *pCr return status; } -A_STATUS DevGMboxReadCreditSize(AR6K_DEVICE *pDev, int *pCreditSize) +int DevGMboxReadCreditSize(struct ar6k_device *pDev, int *pCreditSize) { - A_STATUS status; - A_UINT8 buffer[4]; + int status; + u8 buffer[4]; status = HIFReadWrite(pDev->HIFDevice, AR6K_GMBOX_CREDIT_SIZE_ADDRESS, @@ -614,7 +614,7 @@ A_STATUS DevGMboxReadCreditSize(AR6K_DEVICE *pDev, int *pCreditSize) HIF_RD_SYNC_BYTE_FIX, /* hit the register 4 times to align the I/O */ NULL); - if (A_SUCCESS(status)) { + if (!status) { if (buffer[0] == 0) { *pCreditSize = 256; } else { @@ -626,7 +626,7 @@ A_STATUS DevGMboxReadCreditSize(AR6K_DEVICE *pDev, int *pCreditSize) return status; } -void DevNotifyGMboxTargetFailure(AR6K_DEVICE *pDev) +void DevNotifyGMboxTargetFailure(struct ar6k_device *pDev) { /* Target ASSERTED!!! */ if (pDev->GMboxInfo.pTargetFailureCallback != NULL) { @@ -634,17 +634,17 @@ void DevNotifyGMboxTargetFailure(AR6K_DEVICE *pDev) } } -A_STATUS DevGMboxRecvLookAheadPeek(AR6K_DEVICE *pDev, A_UINT8 *pLookAheadBuffer, int *pLookAheadBytes) +int DevGMboxRecvLookAheadPeek(struct ar6k_device *pDev, u8 *pLookAheadBuffer, int *pLookAheadBytes) { - A_STATUS status = A_OK; - AR6K_IRQ_PROC_REGISTERS procRegs; + int status = 0; + struct ar6k_irq_proc_registers procRegs; int maxCopy; do { /* on entry the caller provides the length of the lookahead buffer */ if (*pLookAheadBytes > sizeof(procRegs.rx_gmbox_lookahead_alias)) { - A_ASSERT(FALSE); + A_ASSERT(false); status = A_EINVAL; break; } @@ -654,12 +654,12 @@ A_STATUS DevGMboxRecvLookAheadPeek(AR6K_DEVICE *pDev, A_UINT8 *pLookAheadBuffer, /* load the register table from the device */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, - (A_UINT8 *)&procRegs, + (u8 *)&procRegs, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DevGMboxRecvLookAheadPeek : Failed to read register table (%d) \n",status)); break; @@ -667,20 +667,20 @@ A_STATUS DevGMboxRecvLookAheadPeek(AR6K_DEVICE *pDev, A_UINT8 *pLookAheadBuffer, if (procRegs.gmbox_rx_avail > 0) { int bytes = procRegs.gmbox_rx_avail > maxCopy ? maxCopy : procRegs.gmbox_rx_avail; - A_MEMCPY(pLookAheadBuffer,&procRegs.rx_gmbox_lookahead_alias[0],bytes); + memcpy(pLookAheadBuffer,&procRegs.rx_gmbox_lookahead_alias[0],bytes); *pLookAheadBytes = bytes; } - } while (FALSE); + } while (false); return status; } -A_STATUS DevGMboxSetTargetInterrupt(AR6K_DEVICE *pDev, int Signal, int AckTimeoutMS) +int DevGMboxSetTargetInterrupt(struct ar6k_device *pDev, int Signal, int AckTimeoutMS) { - A_STATUS status = A_OK; + int status = 0; int i; - A_UINT8 buffer[4]; + u8 buffer[4]; A_MEMZERO(buffer, sizeof(buffer)); @@ -701,14 +701,14 @@ A_STATUS DevGMboxSetTargetInterrupt(AR6K_DEVICE *pDev, int Signal, int AckTimeou HIF_WR_SYNC_BYTE_FIX, /* hit the register 4 times to align the I/O */ NULL); - if (A_FAILED(status)) { + if (status) { break; } - } while (FALSE); + } while (false); - if (A_SUCCESS(status)) { + if (!status) { /* now read back the register to see if the bit cleared */ while (AckTimeoutMS) { status = HIFReadWrite(pDev->HIFDevice, @@ -718,7 +718,7 @@ A_STATUS DevGMboxSetTargetInterrupt(AR6K_DEVICE *pDev, int Signal, int AckTimeou HIF_RD_SYNC_BYTE_FIX, NULL); - if (A_FAILED(status)) { + if (status) { break; } diff --git a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c b/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c index db6d30c..c6488e0 100644 --- a/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c +++ b/drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c @@ -56,17 +56,17 @@ #define BAUD_TIMEOUT_MS 1 #define BTPWRSAV_TIMEOUT_MS 1 -typedef struct { - HCI_TRANSPORT_CONFIG_INFO HCIConfig; - A_BOOL HCIAttached; - A_BOOL HCIStopped; - A_UINT32 RecvStateFlags; - A_UINT32 SendStateFlags; +struct gmbox_proto_hci_uart { + struct hci_transport_config_info HCIConfig; + bool HCIAttached; + bool HCIStopped; + u32 RecvStateFlags; + u32 SendStateFlags; HCI_TRANSPORT_PACKET_TYPE WaitBufferType; - HTC_PACKET_QUEUE SendQueue; /* write queue holding HCI Command and ACL packets */ - HTC_PACKET_QUEUE HCIACLRecvBuffers; /* recv queue holding buffers for incomming ACL packets */ - HTC_PACKET_QUEUE HCIEventBuffers; /* recv queue holding buffers for incomming event packets */ - AR6K_DEVICE *pDev; + struct htc_packet_queue SendQueue; /* write queue holding HCI Command and ACL packets */ + struct htc_packet_queue HCIACLRecvBuffers; /* recv queue holding buffers for incomming ACL packets */ + struct htc_packet_queue HCIEventBuffers; /* recv queue holding buffers for incomming event packets */ + struct ar6k_device *pDev; A_MUTEX_T HCIRxLock; A_MUTEX_T HCITxLock; int CreditsMax; @@ -75,18 +75,23 @@ typedef struct { int CreditSize; int CreditsCurrentSeek; int SendProcessCount; -} GMBOX_PROTO_HCI_UART; +}; #define LOCK_HCI_RX(t) A_MUTEX_LOCK(&(t)->HCIRxLock); #define UNLOCK_HCI_RX(t) A_MUTEX_UNLOCK(&(t)->HCIRxLock); #define LOCK_HCI_TX(t) A_MUTEX_LOCK(&(t)->HCITxLock); #define UNLOCK_HCI_TX(t) A_MUTEX_UNLOCK(&(t)->HCITxLock); -#define DO_HCI_RECV_INDICATION(p,pt) \ -{ AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI: Indicate Recv on packet:0x%lX status:%d len:%d type:%d \n", \ - (unsigned long)(pt),(pt)->Status, A_SUCCESS((pt)->Status) ? (pt)->ActualLength : 0, HCI_GET_PACKET_TYPE(pt))); \ - (p)->HCIConfig.pHCIPktRecv((p)->HCIConfig.pContext, (pt)); \ -} +#define DO_HCI_RECV_INDICATION(p, pt) \ +do { \ + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, \ + ("HCI: Indicate Recv on packet:0x%lX status:%d len:%d type:%d \n", \ + (unsigned long)(pt), \ + (pt)->Status, \ + !(pt)->Status ? (pt)->ActualLength : 0, \ + HCI_GET_PACKET_TYPE(pt))); \ + (p)->HCIConfig.pHCIPktRecv((p)->HCIConfig.pContext, (pt)); \ +} while (0) #define DO_HCI_SEND_INDICATION(p,pt) \ { AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Indicate Send on packet:0x%lX status:%d type:%d \n", \ @@ -94,9 +99,9 @@ typedef struct { (p)->HCIConfig.pHCISendComplete((p)->HCIConfig.pContext, (pt)); \ } -static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_BOOL Synchronous); +static int HCITrySend(struct gmbox_proto_hci_uart *pProt, struct htc_packet *pPacket, bool Synchronous); -static void HCIUartCleanup(GMBOX_PROTO_HCI_UART *pProtocol) +static void HCIUartCleanup(struct gmbox_proto_hci_uart *pProtocol) { A_ASSERT(pProtocol != NULL); @@ -106,12 +111,12 @@ static void HCIUartCleanup(GMBOX_PROTO_HCI_UART *pProtocol) A_FREE(pProtocol); } -static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) +static int InitTxCreditState(struct gmbox_proto_hci_uart *pProt) { - A_STATUS status; + int status; int credits; int creditPollCount = CREDIT_POLL_COUNT; - A_BOOL gotCredits = FALSE; + bool gotCredits = false; pProt->CreditsConsumed = 0; @@ -120,7 +125,7 @@ static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) if (pProt->CreditsMax != 0) { /* we can only call this only once per target reset */ AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI: InitTxCreditState - already called! \n")); - A_ASSERT(FALSE); + A_ASSERT(false); status = A_EINVAL; break; } @@ -135,7 +140,7 @@ static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) status = DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_SYNC, &credits); - if (A_FAILED(status)) { + if (status) { break; } @@ -145,7 +150,7 @@ static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) A_MDELAY(HCI_DELAY_PER_INTERVAL_MS); continue; } else { - gotCredits = TRUE; + gotCredits = true; } if (0 == credits) { @@ -155,7 +160,7 @@ static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) pProt->CreditsMax += credits; } - if (A_FAILED(status)) { + if (status) { break; } @@ -169,13 +174,13 @@ static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) /* now get the size */ status = DevGMboxReadCreditSize(pProt->pDev, &pProt->CreditSize); - if (A_FAILED(status)) { + if (status) { break; } - } while (FALSE); + } while (false); - if (A_SUCCESS(status)) { + if (!status) { pProt->CreditsAvailable = pProt->CreditsMax; AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("HCI : InitTxCreditState - credits avail: %d, size: %d \n", pProt->CreditsAvailable, pProt->CreditSize)); @@ -184,13 +189,13 @@ static A_STATUS InitTxCreditState(GMBOX_PROTO_HCI_UART *pProt) return status; } -static A_STATUS CreditsAvailableCallback(void *pContext, int Credits, A_BOOL CreditIRQEnabled) +static int CreditsAvailableCallback(void *pContext, int Credits, bool CreditIRQEnabled) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)pContext; - A_BOOL enableCreditIrq = FALSE; - A_BOOL disableCreditIrq = FALSE; - A_BOOL doPendingSends = FALSE; - A_STATUS status = A_OK; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; + bool enableCreditIrq = false; + bool disableCreditIrq = false; + bool doPendingSends = false; + int status = 0; /** this callback is called under 2 conditions: * 1. The credit IRQ interrupt was enabled and signaled. @@ -209,7 +214,7 @@ static A_STATUS CreditsAvailableCallback(void *pContext, int Credits, A_BOOL Cre if (0 == Credits) { if (!CreditIRQEnabled) { /* enable credit IRQ */ - enableCreditIrq = TRUE; + enableCreditIrq = true; } break; } @@ -235,19 +240,19 @@ static A_STATUS CreditsAvailableCallback(void *pContext, int Credits, A_BOOL Cre /* we have enough credits to fullfill at least 1 packet waiting in the queue */ pProt->CreditsCurrentSeek = 0; pProt->SendStateFlags &= ~HCI_SEND_WAIT_CREDITS; - doPendingSends = TRUE; + doPendingSends = true; if (CreditIRQEnabled) { /* credit IRQ was enabled, we shouldn't need it anymore */ - disableCreditIrq = TRUE; + disableCreditIrq = true; } } else { /* not enough credits yet, enable credit IRQ if we haven't already */ if (!CreditIRQEnabled) { - enableCreditIrq = TRUE; + enableCreditIrq = true; } } - } while (FALSE); + } while (false); UNLOCK_HCI_TX(pProt); @@ -262,23 +267,23 @@ static A_STATUS CreditsAvailableCallback(void *pContext, int Credits, A_BOOL Cre } if (doPendingSends) { - HCITrySend(pProt, NULL, FALSE); + HCITrySend(pProt, NULL, false); } AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+CreditsAvailableCallback \n")); return status; } -static INLINE void NotifyTransportFailure(GMBOX_PROTO_HCI_UART *pProt, A_STATUS status) +static INLINE void NotifyTransportFailure(struct gmbox_proto_hci_uart *pProt, int status) { if (pProt->HCIConfig.TransportFailure != NULL) { pProt->HCIConfig.TransportFailure(pProt->HCIConfig.pContext, status); } } -static void FailureCallback(void *pContext, A_STATUS Status) +static void FailureCallback(void *pContext, int Status) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)pContext; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; /* target assertion occured */ NotifyTransportFailure(pProt, Status); @@ -286,7 +291,7 @@ static void FailureCallback(void *pContext, A_STATUS Status) static void StateDumpCallback(void *pContext) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)pContext; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("============ HCIUart State ======================\n")); AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("RecvStateFlags : 0x%X \n",pProt->RecvStateFlags)); @@ -299,15 +304,15 @@ static void StateDumpCallback(void *pContext) AR_DEBUG_PRINTF(ATH_DEBUG_ANY,("==================================================\n")); } -static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], int ValidBytes) +static int HCIUartMessagePending(void *pContext, u8 LookAheadBytes[], int ValidBytes) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)pContext; - A_STATUS status = A_OK; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)pContext; + int status = 0; int totalRecvLength = 0; HCI_TRANSPORT_PACKET_TYPE pktType = HCI_PACKET_INVALID; - A_BOOL recvRefillCalled = FALSE; - A_BOOL blockRecv = FALSE; - HTC_PACKET *pPacket = NULL; + bool recvRefillCalled = false; + bool blockRecv = false; + struct htc_packet *pPacket = NULL; /** caller guarantees that this is a fully block-able context (synch I/O is allowed) */ @@ -348,7 +353,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], break; } - if (A_FAILED(status)) { + if (status) { break; } @@ -361,7 +366,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], LOCK_HCI_RX(pProt); } else { - HTC_PACKET_QUEUE *pQueue; + struct htc_packet_queue *pQueue; /* user is using a refill handler that can refill multiple HTC buffers */ /* select buffer queue */ @@ -377,7 +382,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], pktType)); /* check for refill handler */ if (pProt->HCIConfig.pHCIPktRecvRefill != NULL) { - recvRefillCalled = TRUE; + recvRefillCalled = true; UNLOCK_HCI_RX(pProt); /* call the re-fill handler */ pProt->HCIConfig.pHCIPktRecvRefill(pProt->HCIConfig.pContext, @@ -402,7 +407,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], /* this is not an error, we simply need to mark that we are waiting for buffers.*/ pProt->RecvStateFlags |= HCI_RECV_WAIT_BUFFERS; pProt->WaitBufferType = pktType; - blockRecv = TRUE; + blockRecv = true; break; } @@ -413,7 +418,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], break; } - } while (FALSE); + } while (false); UNLOCK_HCI_RX(pProt); @@ -421,7 +426,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], do { - if (A_FAILED(status) || (NULL == pPacket)) { + if (status || (NULL == pPacket)) { break; } @@ -433,7 +438,7 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], status = DevGMboxRead(pProt->pDev, pPacket, totalRecvLength); - if (A_FAILED(status)) { + if (status) { break; } @@ -471,14 +476,14 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], /* adjust buffer to move past packet ID */ pPacket->pBuffer++; pPacket->ActualLength = totalRecvLength - 1; - pPacket->Status = A_OK; + pPacket->Status = 0; /* indicate packet */ DO_HCI_RECV_INDICATION(pProt,pPacket); pPacket = NULL; /* check if we need to refill recv buffers */ if ((pProt->HCIConfig.pHCIPktRecvRefill != NULL) && !recvRefillCalled) { - HTC_PACKET_QUEUE *pQueue; + struct htc_packet_queue *pQueue; int watermark; if (pktType == HCI_ACL_TYPE) { @@ -500,16 +505,16 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], } } - } while (FALSE); + } while (false); /* check if we need to disable the reciever */ - if (A_FAILED(status) || blockRecv) { + if (status || blockRecv) { DevGMboxIRQAction(pProt->pDev, GMBOX_RECV_IRQ_DISABLE, PROC_IO_SYNC); } /* see if we need to recycle the recv buffer */ - if (A_FAILED(status) && (pPacket != NULL)) { - HTC_PACKET_QUEUE queue; + if (status && (pPacket != NULL)) { + struct htc_packet_queue queue; if (A_EPROTO == status) { DebugDumpBytes(pPacket->pBuffer, totalRecvLength, "Bad HCI-UART Recv packet"); @@ -527,12 +532,12 @@ static A_STATUS HCIUartMessagePending(void *pContext, A_UINT8 LookAheadBytes[], return status; } -static void HCISendPacketCompletion(void *Context, HTC_PACKET *pPacket) +static void HCISendPacketCompletion(void *Context, struct htc_packet *pPacket) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)Context; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)Context; AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion (pPacket:0x%lX) \n",(unsigned long)pPacket)); - if (A_FAILED(pPacket->Status)) { + if (pPacket->Status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Send Packet (0x%lX) failed: %d , len:%d \n", (unsigned long)pPacket, pPacket->Status, pPacket->ActualLength)); } @@ -542,16 +547,16 @@ static void HCISendPacketCompletion(void *Context, HTC_PACKET *pPacket) AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion \n")); } -static A_STATUS SeekCreditsSynch(GMBOX_PROTO_HCI_UART *pProt) +static int SeekCreditsSynch(struct gmbox_proto_hci_uart *pProt) { - A_STATUS status = A_OK; + int status = 0; int credits; int retry = 100; - while (TRUE) { + while (true) { credits = 0; status = DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_SYNC, &credits); - if (A_FAILED(status)) { + if (status) { break; } LOCK_HCI_TX(pProt); @@ -574,13 +579,13 @@ static A_STATUS SeekCreditsSynch(GMBOX_PROTO_HCI_UART *pProt) return status; } -static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_BOOL Synchronous) +static int HCITrySend(struct gmbox_proto_hci_uart *pProt, struct htc_packet *pPacket, bool Synchronous) { - A_STATUS status = A_OK; + int status = 0; int transferLength; int creditsRequired, remainder; - A_UINT8 hciUartType; - A_BOOL synchSendComplete = FALSE; + u8 hciUartType; + bool synchSendComplete = false; AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCITrySend (pPacket:0x%lX) %s \n",(unsigned long)pPacket, Synchronous ? "SYNC" :"ASYNC")); @@ -603,14 +608,14 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B /* in synchronous mode, the send queue can only hold 1 packet */ if (!HTC_QUEUE_EMPTY(&pProt->SendQueue)) { status = A_EBUSY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } if (pProt->SendProcessCount > 1) { /* another thread or task is draining the TX queues */ status = A_EBUSY; - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -667,11 +672,11 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B break; default: status = A_EINVAL; - A_ASSERT(FALSE); + A_ASSERT(false); break; } - if (A_FAILED(status)) { + if (status) { break; } @@ -701,7 +706,7 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B UNLOCK_HCI_TX(pProt); status = SeekCreditsSynch(pProt); LOCK_HCI_TX(pProt); - if (A_FAILED(status)) { + if (status) { break; } /* fall through and continue processing this send op */ @@ -751,7 +756,7 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B status = DevGMboxWrite(pProt->pDev,pPacket,transferLength); if (Synchronous) { - synchSendComplete = TRUE; + synchSendComplete = true; } else { pPacket = NULL; } @@ -760,7 +765,7 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B } - } while (FALSE); + } while (false); pProt->SendProcessCount--; A_ASSERT(pProt->SendProcessCount >= 0); @@ -768,9 +773,9 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B if (Synchronous) { A_ASSERT(pPacket != NULL); - if (A_SUCCESS(status) && (!synchSendComplete)) { + if (!status && (!synchSendComplete)) { status = A_EBUSY; - A_ASSERT(FALSE); + A_ASSERT(false); LOCK_HCI_TX(pProt); if (pPacket->ListLink.pNext != NULL) { /* remove from the queue */ @@ -779,7 +784,7 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B UNLOCK_HCI_TX(pProt); } } else { - if (A_FAILED(status) && (pPacket != NULL)) { + if (status && (pPacket != NULL)) { pPacket->Status = status; DO_HCI_SEND_INDICATION(pProt,pPacket); } @@ -789,10 +794,10 @@ static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B return status; } -static void FlushSendQueue(GMBOX_PROTO_HCI_UART *pProt) +static void FlushSendQueue(struct gmbox_proto_hci_uart *pProt) { - HTC_PACKET *pPacket; - HTC_PACKET_QUEUE discardQueue; + struct htc_packet *pPacket; + struct htc_packet_queue discardQueue; INIT_HTC_PACKET_QUEUE(&discardQueue); @@ -813,10 +818,10 @@ static void FlushSendQueue(GMBOX_PROTO_HCI_UART *pProt) } -static void FlushRecvBuffers(GMBOX_PROTO_HCI_UART *pProt) +static void FlushRecvBuffers(struct gmbox_proto_hci_uart *pProt) { - HTC_PACKET_QUEUE discardQueue; - HTC_PACKET *pPacket; + struct htc_packet_queue discardQueue; + struct htc_packet *pPacket; INIT_HTC_PACKET_QUEUE(&discardQueue); @@ -841,14 +846,14 @@ static void FlushRecvBuffers(GMBOX_PROTO_HCI_UART *pProt) /*** protocol module install entry point ***/ -A_STATUS GMboxProtocolInstall(AR6K_DEVICE *pDev) +int GMboxProtocolInstall(struct ar6k_device *pDev) { - A_STATUS status = A_OK; - GMBOX_PROTO_HCI_UART *pProtocol = NULL; + int status = 0; + struct gmbox_proto_hci_uart *pProtocol = NULL; do { - pProtocol = A_MALLOC(sizeof(GMBOX_PROTO_HCI_UART)); + pProtocol = A_MALLOC(sizeof(struct gmbox_proto_hci_uart)); if (NULL == pProtocol) { status = A_NO_MEMORY; @@ -863,9 +868,9 @@ A_STATUS GMboxProtocolInstall(AR6K_DEVICE *pDev) A_MUTEX_INIT(&pProtocol->HCIRxLock); A_MUTEX_INIT(&pProtocol->HCITxLock); - } while (FALSE); + } while (false); - if (A_SUCCESS(status)) { + if (!status) { LOCK_AR6K(pDev); DEV_GMBOX_SET_PROTOCOL(pDev, HCIUartMessagePending, @@ -884,9 +889,9 @@ A_STATUS GMboxProtocolInstall(AR6K_DEVICE *pDev) } /*** protocol module uninstall entry point ***/ -void GMboxProtocolUninstall(AR6K_DEVICE *pDev) +void GMboxProtocolUninstall(struct ar6k_device *pDev) { - GMBOX_PROTO_HCI_UART *pProtocol = (GMBOX_PROTO_HCI_UART *)DEV_GMBOX_GET_PROTOCOL(pDev); + struct gmbox_proto_hci_uart *pProtocol = (struct gmbox_proto_hci_uart *)DEV_GMBOX_GET_PROTOCOL(pDev); if (pProtocol != NULL) { @@ -894,7 +899,7 @@ void GMboxProtocolUninstall(AR6K_DEVICE *pDev) if (pProtocol->HCIAttached) { A_ASSERT(pProtocol->HCIConfig.TransportRemoved != NULL); pProtocol->HCIConfig.TransportRemoved(pProtocol->HCIConfig.pContext); - pProtocol->HCIAttached = FALSE; + pProtocol->HCIAttached = false; } HCIUartCleanup(pProtocol); @@ -903,10 +908,10 @@ void GMboxProtocolUninstall(AR6K_DEVICE *pDev) } -static A_STATUS NotifyTransportReady(GMBOX_PROTO_HCI_UART *pProt) +static int NotifyTransportReady(struct gmbox_proto_hci_uart *pProt) { - HCI_TRANSPORT_PROPERTIES props; - A_STATUS status = A_OK; + struct hci_transport_properties props; + int status = 0; do { @@ -924,17 +929,17 @@ static A_STATUS NotifyTransportReady(GMBOX_PROTO_HCI_UART *pProt) pProt->HCIConfig.pContext); } - } while (FALSE); + } while (false); return status; } /*********** HCI UART protocol implementation ************************************************/ -HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, HCI_TRANSPORT_CONFIG_INFO *pInfo) +HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, struct hci_transport_config_info *pInfo) { - GMBOX_PROTO_HCI_UART *pProtocol = NULL; - AR6K_DEVICE *pDev; + struct gmbox_proto_hci_uart *pProtocol = NULL; + struct ar6k_device *pDev; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportAttach \n")); @@ -944,7 +949,7 @@ HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, HCI_TRANSPORT_CONFIG_I do { - pProtocol = (GMBOX_PROTO_HCI_UART *)DEV_GMBOX_GET_PROTOCOL(pDev); + pProtocol = (struct gmbox_proto_hci_uart *)DEV_GMBOX_GET_PROTOCOL(pDev); if (NULL == pProtocol) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("GMBOX protocol not installed! \n")); @@ -956,14 +961,14 @@ HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, HCI_TRANSPORT_CONFIG_I break; } - A_MEMCPY(&pProtocol->HCIConfig, pInfo, sizeof(HCI_TRANSPORT_CONFIG_INFO)); + memcpy(&pProtocol->HCIConfig, pInfo, sizeof(struct hci_transport_config_info)); A_ASSERT(pProtocol->HCIConfig.pHCIPktRecv != NULL); A_ASSERT(pProtocol->HCIConfig.pHCISendComplete != NULL); - pProtocol->HCIAttached = TRUE; + pProtocol->HCIAttached = true; - } while (FALSE); + } while (false); UNLOCK_AR6K(pDev); @@ -978,8 +983,8 @@ HCI_TRANSPORT_HANDLE HCI_TransportAttach(void *HTCHandle, HCI_TRANSPORT_CONFIG_I void HCI_TransportDetach(HCI_TRANSPORT_HANDLE HciTrans) { - GMBOX_PROTO_HCI_UART *pProtocol = (GMBOX_PROTO_HCI_UART *)HciTrans; - AR6K_DEVICE *pDev = pProtocol->pDev; + struct gmbox_proto_hci_uart *pProtocol = (struct gmbox_proto_hci_uart *)HciTrans; + struct ar6k_device *pDev = pProtocol->pDev; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportDetach \n")); @@ -989,19 +994,19 @@ void HCI_TransportDetach(HCI_TRANSPORT_HANDLE HciTrans) UNLOCK_AR6K(pDev); return; } - pProtocol->HCIAttached = FALSE; + pProtocol->HCIAttached = false; UNLOCK_AR6K(pDev); HCI_TransportStop(HciTrans); AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportAttach \n")); } -A_STATUS HCI_TransportAddReceivePkts(HCI_TRANSPORT_HANDLE HciTrans, HTC_PACKET_QUEUE *pQueue) +int HCI_TransportAddReceivePkts(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet_queue *pQueue) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; - A_STATUS status = A_OK; - A_BOOL unblockRecv = FALSE; - HTC_PACKET *pPacket; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; + int status = 0; + bool unblockRecv = false; + struct htc_packet *pPacket; AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HCI_TransportAddReceivePkt \n")); @@ -1039,15 +1044,15 @@ A_STATUS HCI_TransportAddReceivePkts(HCI_TRANSPORT_HANDLE HciTrans, HTC_PACKET_Q pProt->WaitBufferType)); pProt->RecvStateFlags &= ~HCI_RECV_WAIT_BUFFERS; pProt->WaitBufferType = HCI_PACKET_INVALID; - unblockRecv = TRUE; + unblockRecv = true; } } - } while (FALSE); + } while (false); UNLOCK_HCI_RX(pProt); - if (A_FAILED(status)) { + if (status) { while (!HTC_QUEUE_EMPTY(pQueue)) { pPacket = HTC_PACKET_DEQUEUE(pQueue); pPacket->Status = A_ECANCELED; @@ -1061,19 +1066,19 @@ A_STATUS HCI_TransportAddReceivePkts(HCI_TRANSPORT_HANDLE HciTrans, HTC_PACKET_Q AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HCI_TransportAddReceivePkt \n")); - return A_OK; + return 0; } -A_STATUS HCI_TransportSendPkt(HCI_TRANSPORT_HANDLE HciTrans, HTC_PACKET *pPacket, A_BOOL Synchronous) +int HCI_TransportSendPkt(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, bool Synchronous) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; return HCITrySend(pProt,pPacket,Synchronous); } void HCI_TransportStop(HCI_TRANSPORT_HANDLE HciTrans) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportStop \n")); @@ -1083,7 +1088,7 @@ void HCI_TransportStop(HCI_TRANSPORT_HANDLE HciTrans) AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportStop \n")); return; } - pProt->HCIStopped = TRUE; + pProt->HCIStopped = true; UNLOCK_AR6K(pProt->pDev); /* disable interrupts */ @@ -1097,69 +1102,69 @@ void HCI_TransportStop(HCI_TRANSPORT_HANDLE HciTrans) AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportStop \n")); } -A_STATUS HCI_TransportStart(HCI_TRANSPORT_HANDLE HciTrans) +int HCI_TransportStart(HCI_TRANSPORT_HANDLE HciTrans) { - A_STATUS status; - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; + int status; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportStart \n")); /* set stopped in case we have a problem in starting */ - pProt->HCIStopped = TRUE; + pProt->HCIStopped = true; do { status = InitTxCreditState(pProt); - if (A_FAILED(status)) { + if (status) { break; } status = DevGMboxIRQAction(pProt->pDev, GMBOX_ERRORS_IRQ_ENABLE, PROC_IO_SYNC); - if (A_FAILED(status)) { + if (status) { break; } /* enable recv */ status = DevGMboxIRQAction(pProt->pDev, GMBOX_RECV_IRQ_ENABLE, PROC_IO_SYNC); - if (A_FAILED(status)) { + if (status) { break; } /* signal bridge side to power up BT */ status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_BT_ON, BTON_TIMEOUT_MS); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI_TransportStart : Failed to trigger BT ON \n")); break; } /* we made it */ - pProt->HCIStopped = FALSE; + pProt->HCIStopped = false; - } while (FALSE); + } while (false); AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportStart \n")); return status; } -A_STATUS HCI_TransportEnableDisableAsyncRecv(HCI_TRANSPORT_HANDLE HciTrans, A_BOOL Enable) +int HCI_TransportEnableDisableAsyncRecv(HCI_TRANSPORT_HANDLE HciTrans, bool Enable) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; return DevGMboxIRQAction(pProt->pDev, Enable ? GMBOX_RECV_IRQ_ENABLE : GMBOX_RECV_IRQ_DISABLE, PROC_IO_SYNC); } -A_STATUS HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, - HTC_PACKET *pPacket, +int HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, + struct htc_packet *pPacket, int MaxPollMS) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; - A_STATUS status = A_OK; - A_UINT8 lookAhead[8]; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; + int status = 0; + u8 lookAhead[8]; int bytes; int totalRecvLength; @@ -1173,7 +1178,7 @@ A_STATUS HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, bytes = sizeof(lookAhead); status = DevGMboxRecvLookAheadPeek(pProt->pDev,lookAhead,&bytes); - if (A_FAILED(status)) { + if (status) { break; } @@ -1199,19 +1204,19 @@ A_STATUS HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, break; } - if (A_FAILED(status)) { + if (status) { break; } pPacket->Completion = NULL; status = DevGMboxRead(pProt->pDev,pPacket,totalRecvLength); - if (A_FAILED(status)) { + if (status) { break; } pPacket->pBuffer++; pPacket->ActualLength = totalRecvLength - 1; - pPacket->Status = A_OK; + pPacket->Status = 0; break; } @@ -1225,12 +1230,12 @@ A_STATUS HCI_TransportRecvHCIEventSync(HCI_TRANSPORT_HANDLE HciTrans, #define LSB_SCRATCH_IDX 4 #define MSB_SCRATCH_IDX 5 -A_STATUS HCI_TransportSetBaudRate(HCI_TRANSPORT_HANDLE HciTrans, A_UINT32 Baud) +int HCI_TransportSetBaudRate(HCI_TRANSPORT_HANDLE HciTrans, u32 Baud) { - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; - HIF_DEVICE *pHIFDevice = (HIF_DEVICE *)(pProt->pDev->HIFDevice); - A_UINT32 scaledBaud, scratchAddr; - A_STATUS status = A_OK; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; + struct hif_device *pHIFDevice = (struct hif_device *)(pProt->pDev->HIFDevice); + u32 scaledBaud, scratchAddr; + int status = 0; /* Divide the desired baud rate by 100 * Store the LSB in the local scratch register 4 and the MSB in the local @@ -1242,24 +1247,24 @@ A_STATUS HCI_TransportSetBaudRate(HCI_TRANSPORT_HANDLE HciTrans, A_UINT32 Baud) scratchAddr = MBOX_BASE_ADDRESS | (LOCAL_SCRATCH_ADDRESS + 4 * MSB_SCRATCH_IDX); scaledBaud = ((Baud / 100) >> (LOCAL_SCRATCH_VALUE_MSB+1)) & LOCAL_SCRATCH_VALUE_MASK; status |= ar6000_WriteRegDiag(pHIFDevice, &scratchAddr, &scaledBaud); - if (A_OK != status) { + if (0 != status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to set up baud rate in scratch register!")); return status; } /* Now interrupt the target to tell it about the baud rate */ status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_BAUD_SET, BAUD_TIMEOUT_MS); - if (A_OK != status) { + if (0 != status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to tell target to change baud rate!")); } return status; } -A_STATUS HCI_TransportEnablePowerMgmt(HCI_TRANSPORT_HANDLE HciTrans, A_BOOL Enable) +int HCI_TransportEnablePowerMgmt(HCI_TRANSPORT_HANDLE HciTrans, bool Enable) { - A_STATUS status; - GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)HciTrans; + int status; + struct gmbox_proto_hci_uart *pProt = (struct gmbox_proto_hci_uart *)HciTrans; if (Enable) { status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_PWR_SAV_ON, BTPWRSAV_TIMEOUT_MS); @@ -1267,7 +1272,7 @@ A_STATUS HCI_TransportEnablePowerMgmt(HCI_TRANSPORT_HANDLE HciTrans, A_BOOL Enab status = DevGMboxSetTargetInterrupt(pProt->pDev, MBOX_SIG_HCI_BRIDGE_PWR_SAV_OFF, BTPWRSAV_TIMEOUT_MS); } - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to enable/disable HCI power management!\n")); } else { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI power management enabled/disabled!\n")); diff --git a/drivers/staging/ath6kl/htc2/htc.c b/drivers/staging/ath6kl/htc2/htc.c index 7df62a2..d40bb14 100644 --- a/drivers/staging/ath6kl/htc2/htc.c +++ b/drivers/staging/ath6kl/htc2/htc.c @@ -23,7 +23,7 @@ #include "htc_internal.h" #ifdef ATH_DEBUG_MODULE -static ATH_DEBUG_MASK_DESCRIPTION g_HTCDebugDescription[] = { +static struct ath_debug_mask_description g_HTCDebugDescription[] = { { ATH_DEBUG_SEND , "Send"}, { ATH_DEBUG_RECV , "Recv"}, { ATH_DEBUG_SYNC , "Sync"}, @@ -41,18 +41,18 @@ ATH_DEBUG_INSTANTIATE_MODULE_VAR(htc, #endif static void HTCReportFailure(void *Context); -static void ResetEndpointStates(HTC_TARGET *target); +static void ResetEndpointStates(struct htc_target *target); -void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PACKET_QUEUE *pList) +void HTCFreeControlBuffer(struct htc_target *target, struct htc_packet *pPacket, struct htc_packet_queue *pList) { LOCK_HTC(target); HTC_PACKET_ENQUEUE(pList,pPacket); UNLOCK_HTC(target); } -HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList) +struct htc_packet *HTCAllocControlBuffer(struct htc_target *target, struct htc_packet_queue *pList) { - HTC_PACKET *pPacket; + struct htc_packet *pPacket; LOCK_HTC(target); pPacket = HTC_PACKET_DEQUEUE(pList); @@ -62,9 +62,9 @@ HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList) } /* cleanup the HTC instance */ -static void HTCCleanup(HTC_TARGET *target) +static void HTCCleanup(struct htc_target *target) { - A_INT32 i; + s32 i; DevCleanup(&target->Device); @@ -90,13 +90,13 @@ static void HTCCleanup(HTC_TARGET *target) } /* registered target arrival callback from the HIF layer */ -HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) +HTC_HANDLE HTCCreate(void *hif_handle, struct htc_init_info *pInfo) { - HTC_TARGET *target = NULL; - A_STATUS status = A_OK; + struct htc_target *target = NULL; + int status = 0; int i; - A_UINT32 ctrl_bufsz; - A_UINT32 blocksizes[HTC_MAILBOX_NUM_MAX]; + u32 ctrl_bufsz; + u32 blocksizes[HTC_MAILBOX_NUM_MAX]; AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCCreate - Enter\n")); @@ -105,13 +105,13 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) do { /* allocate target memory */ - if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) { + if ((target = (struct htc_target *)A_MALLOC(sizeof(struct htc_target))) == NULL) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to allocate memory\n")); status = A_ERROR; break; } - A_MEMZERO(target, sizeof(HTC_TARGET)); + A_MEMZERO(target, sizeof(struct htc_target)); A_MUTEX_INIT(&target->HTCLock); A_MUTEX_INIT(&target->HTCRxLock); A_MUTEX_INIT(&target->HTCTxLock); @@ -130,14 +130,14 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) target->Device.MessagePendingCallback = HTCRecvMessagePendingHandler; target->EpWaitingForBuffers = ENDPOINT_MAX; - A_MEMCPY(&target->HTCInitInfo,pInfo,sizeof(HTC_INIT_INFO)); + memcpy(&target->HTCInitInfo,pInfo,sizeof(struct htc_init_info)); ResetEndpointStates(target); /* setup device layer */ status = DevSetup(&target->Device); - if (A_FAILED(status)) { + if (status) { break; } @@ -145,7 +145,7 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) /* get the block sizes */ status = HIFConfigureDevice(hif_handle, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, blocksizes, sizeof(blocksizes)); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to get block size info from HIF layer...\n")); break; } @@ -165,13 +165,13 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) } } - if (A_FAILED(status)) { + if (status) { break; } /* carve up buffers/packets for control messages */ for (i = 0; i < NUM_CONTROL_RX_BUFFERS; i++) { - HTC_PACKET *pControlPacket; + struct htc_packet *pControlPacket; pControlPacket = &target->HTCControlBuffers[i].HtcPacket; SET_HTC_PACKET_INFO_RX_REFILL(pControlPacket, target, @@ -182,7 +182,7 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) } for (;i < NUM_CONTROL_BUFFERS;i++) { - HTC_PACKET *pControlPacket; + struct htc_packet *pControlPacket; pControlPacket = &target->HTCControlBuffers[i].HtcPacket; INIT_HTC_PACKET_INFO(pControlPacket, target->HTCControlBuffers[i].Buffer, @@ -190,9 +190,9 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) HTC_FREE_CONTROL_TX(target,pControlPacket); } - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { if (target != NULL) { HTCCleanup(target); target = NULL; @@ -206,7 +206,7 @@ HTC_HANDLE HTCCreate(void *hif_handle, HTC_INIT_INFO *pInfo) void HTCDestroy(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCDestroy .. Destroying :0x%lX \n",(unsigned long)target)); HTCCleanup(target); AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCDestroy \n")); @@ -216,21 +216,21 @@ void HTCDestroy(HTC_HANDLE HTCHandle) * HIF requests */ void *HTCGetHifDevice(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); return target->Device.HIFDevice; } /* wait for the target to arrive (sends HTC Ready message) * this operation is fully synchronous and the message is polled for */ -A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) +int HTCWaitTarget(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - A_STATUS status; - HTC_PACKET *pPacket = NULL; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + int status; + struct htc_packet *pPacket = NULL; HTC_READY_EX_MSG *pRdyMsg; - HTC_SERVICE_CONNECT_REQ connect; - HTC_SERVICE_CONNECT_RESP resp; + struct htc_service_connect_req connect; + struct htc_service_connect_resp resp; AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Enter (target:0x%lX) \n", (unsigned long)target)); @@ -240,7 +240,7 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) status = DoMboxHWTest(&target->Device); - if (status != A_OK) { + if (status) { break; } @@ -249,7 +249,7 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) /* we should be getting 1 control message that the target is ready */ status = HTCWaitforControlMessage(target, &pPacket); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Target Not Available!!\n")); break; } @@ -260,7 +260,7 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) if ((pRdyMsg->Version2_0_Info.MessageID != HTC_MSG_READY_ID) || (pPacket->ActualLength < sizeof(HTC_READY_MSG))) { /* this message is not valid */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_EPROTO; break; } @@ -268,7 +268,7 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) if (pRdyMsg->Version2_0_Info.CreditCount == 0 || pRdyMsg->Version2_0_Info.CreditSize == 0) { /* this message is not valid */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_EPROTO; break; } @@ -305,7 +305,7 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) /* limit what HTC can handle */ target->MaxMsgPerBundle = min(HTC_HOST_MAX_MSG_PER_BUNDLE, target->MaxMsgPerBundle); /* target supports message bundling, setup device layer */ - if (A_FAILED(DevSetupMsgBundling(&target->Device,target->MaxMsgPerBundle))) { + if (DevSetupMsgBundling(&target->Device,target->MaxMsgPerBundle)) { /* device layer can't handle bundling */ target->MaxMsgPerBundle = 0; } else { @@ -320,10 +320,10 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) (" HTC bundling allowed. Max Msg Per HTC Bundle: %d\n", target->MaxMsgPerBundle)); if (DEV_GET_MAX_BUNDLE_SEND_LENGTH(&target->Device) != 0) { - target->SendBundlingEnabled = TRUE; + target->SendBundlingEnabled = true; } if (DEV_GET_MAX_BUNDLE_RECV_LENGTH(&target->Device) != 0) { - target->RecvBundlingEnabled = TRUE; + target->RecvBundlingEnabled = true; } if (!DEV_IS_LEN_BLOCK_ALIGNED(&target->Device,target->TargetCreditSize)) { @@ -331,7 +331,7 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) target->TargetCreditSize)); /* disallow send bundling since the credit size is not aligned to a block size * the I/O block padding will spill into the next credit buffer which is fatal */ - target->SendBundlingEnabled = FALSE; + target->SendBundlingEnabled = false; } } @@ -351,11 +351,11 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) &connect, &resp); - if (!A_FAILED(status)) { + if (!status) { break; } - } while (FALSE); + } while (false); if (pPacket != NULL) { HTC_FREE_CONTROL_RX(target,pPacket); @@ -369,11 +369,11 @@ A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) /* Start HTC, enable interrupts and let the target know host has finished setup */ -A_STATUS HTCStart(HTC_HANDLE HTCHandle) +int HTCStart(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - HTC_PACKET *pPacket; - A_STATUS status; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_packet *pPacket; + int status; AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Enter\n")); @@ -419,26 +419,26 @@ A_STATUS HTCStart(HTC_HANDLE HTCHandle) * target that the setup phase is complete */ status = HTCSendSetupComplete(target); - if (A_FAILED(status)) { + if (status) { break; } /* unmask interrupts */ status = DevUnmaskInterrupts(&target->Device); - if (A_FAILED(status)) { + if (status) { HTCStop(target); } - } while (FALSE); + } while (false); AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Exit\n")); return status; } -static void ResetEndpointStates(HTC_TARGET *target) +static void ResetEndpointStates(struct htc_target *target) { - HTC_ENDPOINT *pEndpoint; + struct htc_endpoint *pEndpoint; int i; for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) { @@ -463,7 +463,7 @@ static void ResetEndpointStates(HTC_TARGET *target) /* stop HTC communications, i.e. stop interrupt reception, and flush all queued buffers */ void HTCStop(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCStop \n")); LOCK_HTC(target); @@ -486,6 +486,8 @@ void HTCStop(HTC_HANDLE HTCHandle) /* flush all recv buffers */ HTCFlushRecvBuffers(target); + DevCleanupMsgBundling(&target->Device); + ResetEndpointStates(target); AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCStop \n")); @@ -494,7 +496,7 @@ void HTCStop(HTC_HANDLE HTCHandle) #ifdef ATH_DEBUG_MODULE void HTCDumpCreditStates(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); LOCK_HTC_TX(target); @@ -509,9 +511,9 @@ void HTCDumpCreditStates(HTC_HANDLE HTCHandle) * which uses a mechanism to report errors from the target (i.e. special interrupts) */ static void HTCReportFailure(void *Context) { - HTC_TARGET *target = (HTC_TARGET *)Context; + struct htc_target *target = (struct htc_target *)Context; - target->TargetFailure = TRUE; + target->TargetFailure = true; if (target->HTCInitInfo.TargetFailure != NULL) { /* let upper layer know, it needs to call HTCStop() */ @@ -519,27 +521,27 @@ static void HTCReportFailure(void *Context) } } -A_BOOL HTCGetEndpointStatistics(HTC_HANDLE HTCHandle, +bool HTCGetEndpointStatistics(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_ENDPOINT_STAT_ACTION Action, - HTC_ENDPOINT_STATS *pStats) + struct htc_endpoint_stats *pStats) { #ifdef HTC_EP_STAT_PROFILING - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - A_BOOL clearStats = FALSE; - A_BOOL sample = FALSE; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + bool clearStats = false; + bool sample = false; switch (Action) { case HTC_EP_STAT_SAMPLE : - sample = TRUE; + sample = true; break; case HTC_EP_STAT_SAMPLE_AND_CLEAR : - sample = TRUE; - clearStats = TRUE; + sample = true; + clearStats = true; break; case HTC_EP_STAT_CLEAR : - clearStats = TRUE; + clearStats = true; break; default: break; @@ -554,26 +556,26 @@ A_BOOL HTCGetEndpointStatistics(HTC_HANDLE HTCHandle, if (sample) { A_ASSERT(pStats != NULL); /* return the stats to the caller */ - A_MEMCPY(pStats, &target->EndPoint[Endpoint].EndPointStats, sizeof(HTC_ENDPOINT_STATS)); + memcpy(pStats, &target->EndPoint[Endpoint].EndPointStats, sizeof(struct htc_endpoint_stats)); } if (clearStats) { /* reset stats */ - A_MEMZERO(&target->EndPoint[Endpoint].EndPointStats, sizeof(HTC_ENDPOINT_STATS)); + A_MEMZERO(&target->EndPoint[Endpoint].EndPointStats, sizeof(struct htc_endpoint_stats)); } UNLOCK_HTC_RX(target); UNLOCK_HTC_TX(target); - return TRUE; + return true; #else - return FALSE; + return false; #endif } -AR6K_DEVICE *HTCGetAR6KDevice(void *HTCHandle) +struct ar6k_device *HTCGetAR6KDevice(void *HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); return &target->Device; } diff --git a/drivers/staging/ath6kl/htc2/htc_internal.h b/drivers/staging/ath6kl/htc2/htc_internal.h index bd6754b..9425ed9 100644 --- a/drivers/staging/ath6kl/htc2/htc_internal.h +++ b/drivers/staging/ath6kl/htc2/htc_internal.h @@ -65,27 +65,27 @@ extern "C" { #define HTC_SCATTER_REQ_FLAGS_PARTIAL_BUNDLE (1 << 0) -typedef struct _HTC_ENDPOINT { +struct htc_endpoint { HTC_ENDPOINT_ID Id; HTC_SERVICE_ID ServiceID; /* service ID this endpoint is bound to non-zero value means this endpoint is in use */ - HTC_PACKET_QUEUE TxQueue; /* HTC frame buffer TX queue */ - HTC_PACKET_QUEUE RxBuffers; /* HTC frame buffer RX list */ - HTC_ENDPOINT_CREDIT_DIST CreditDist; /* credit distribution structure (exposed to driver layer) */ - HTC_EP_CALLBACKS EpCallBacks; /* callbacks associated with this endpoint */ + struct htc_packet_queue TxQueue; /* HTC frame buffer TX queue */ + struct htc_packet_queue RxBuffers; /* HTC frame buffer RX list */ + struct htc_endpoint_credit_dist CreditDist; /* credit distribution structure (exposed to driver layer) */ + struct htc_ep_callbacks EpCallBacks; /* callbacks associated with this endpoint */ int MaxTxQueueDepth; /* max depth of the TX queue before we need to call driver's full handler */ int MaxMsgLength; /* max length of endpoint message */ int TxProcessCount; /* reference count to continue tx processing */ - HTC_PACKET_QUEUE RecvIndicationQueue; /* recv packets ready to be indicated */ + struct htc_packet_queue RecvIndicationQueue; /* recv packets ready to be indicated */ int RxProcessCount; /* reference count to allow single processing context */ - struct _HTC_TARGET *target; /* back pointer to target */ - A_UINT8 SeqNo; /* TX seq no (helpful) for debugging */ - A_UINT32 LocalConnectionFlags; /* local connection flags */ + struct htc_target *target; /* back pointer to target */ + u8 SeqNo; /* TX seq no (helpful) for debugging */ + u32 LocalConnectionFlags; /* local connection flags */ #ifdef HTC_EP_STAT_PROFILING - HTC_ENDPOINT_STATS EndPointStats; /* endpoint statistics */ + struct htc_endpoint_stats EndPointStats; /* endpoint statistics */ #endif -} HTC_ENDPOINT; +}; #ifdef HTC_EP_STAT_PROFILING #define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count); @@ -99,21 +99,21 @@ typedef struct _HTC_ENDPOINT { #define NUM_CONTROL_TX_BUFFERS 2 #define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS) -typedef struct HTC_CONTROL_BUFFER { - HTC_PACKET HtcPacket; - A_UINT8 *Buffer; -} HTC_CONTROL_BUFFER; +struct htc_control_buffer { + struct htc_packet HtcPacket; + u8 *Buffer; +}; #define HTC_RECV_WAIT_BUFFERS (1 << 0) #define HTC_OP_STATE_STOPPING (1 << 0) /* our HTC target state */ -typedef struct _HTC_TARGET { - HTC_ENDPOINT EndPoint[ENDPOINT_MAX]; - HTC_CONTROL_BUFFER HTCControlBuffers[NUM_CONTROL_BUFFERS]; - HTC_ENDPOINT_CREDIT_DIST *EpCreditDistributionListHead; - HTC_PACKET_QUEUE ControlBufferTXFreeList; - HTC_PACKET_QUEUE ControlBufferRXFreeList; +struct htc_target { + struct htc_endpoint EndPoint[ENDPOINT_MAX]; + struct htc_control_buffer HTCControlBuffers[NUM_CONTROL_BUFFERS]; + struct htc_endpoint_credit_dist *EpCreditDistributionListHead; + struct htc_packet_queue ControlBufferTXFreeList; + struct htc_packet_queue ControlBufferRXFreeList; HTC_CREDIT_DIST_CALLBACK DistributeCredits; HTC_CREDIT_INIT_CALLBACK InitCredits; void *pCredDistContext; @@ -122,22 +122,22 @@ typedef struct _HTC_TARGET { A_MUTEX_T HTCLock; A_MUTEX_T HTCRxLock; A_MUTEX_T HTCTxLock; - AR6K_DEVICE Device; /* AR6K - specific state */ - A_UINT32 OpStateFlags; - A_UINT32 RecvStateFlags; + struct ar6k_device Device; /* AR6K - specific state */ + u32 OpStateFlags; + u32 RecvStateFlags; HTC_ENDPOINT_ID EpWaitingForBuffers; - A_BOOL TargetFailure; + bool TargetFailure; #ifdef HTC_CAPTURE_LAST_FRAME - HTC_FRAME_HDR LastFrameHdr; /* useful for debugging */ - A_UINT8 LastTrailer[256]; - A_UINT8 LastTrailerLength; + struct htc_frame_hdr LastFrameHdr; /* useful for debugging */ + u8 LastTrailer[256]; + u8 LastTrailerLength; #endif - HTC_INIT_INFO HTCInitInfo; - A_UINT8 HTCTargetVersion; + struct htc_init_info HTCInitInfo; + u8 HTCTargetVersion; int MaxMsgPerBundle; /* max messages per bundle for HTC */ - A_BOOL SendBundlingEnabled; /* run time enable for send bundling (dynamic) */ + bool SendBundlingEnabled; /* run time enable for send bundling (dynamic) */ int RecvBundlingEnabled; /* run time enable for recv bundling (dynamic) */ -} HTC_TARGET; +}; #define HTC_STOPPING(t) ((t)->OpStateFlags & HTC_OP_STATE_STOPPING) #define LOCK_HTC(t) A_MUTEX_LOCK(&(t)->HTCLock); @@ -147,7 +147,7 @@ typedef struct _HTC_TARGET { #define LOCK_HTC_TX(t) A_MUTEX_LOCK(&(t)->HTCTxLock); #define UNLOCK_HTC_TX(t) A_MUTEX_UNLOCK(&(t)->HTCTxLock); -#define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd)) +#define GET_HTC_TARGET_FROM_HANDLE(hnd) ((struct htc_target *)(hnd)) #define HTC_RECYCLE_RX_PKT(target,p,e) \ { \ if ((p)->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_NO_RECYCLE) { \ @@ -162,27 +162,27 @@ typedef struct _HTC_TARGET { } /* internal HTC functions */ -void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket); -void HTCControlRecv(void *Context, HTC_PACKET *pPacket); -A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPacket); -HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList); -void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PACKET_QUEUE *pList); -A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket); -void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket); -A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], int NumLookAheads, A_BOOL *pAsyncProc, int *pNumPktsFetched); -void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint); -A_STATUS HTCSendSetupComplete(HTC_TARGET *target); -void HTCFlushRecvBuffers(HTC_TARGET *target); -void HTCFlushSendPkts(HTC_TARGET *target); +void HTCControlTxComplete(void *Context, struct htc_packet *pPacket); +void HTCControlRecv(void *Context, struct htc_packet *pPacket); +int HTCWaitforControlMessage(struct htc_target *target, struct htc_packet **ppControlPacket); +struct htc_packet *HTCAllocControlBuffer(struct htc_target *target, struct htc_packet_queue *pList); +void HTCFreeControlBuffer(struct htc_target *target, struct htc_packet *pPacket, struct htc_packet_queue *pList); +int HTCIssueSend(struct htc_target *target, struct htc_packet *pPacket); +void HTCRecvCompleteHandler(void *Context, struct htc_packet *pPacket); +int HTCRecvMessagePendingHandler(void *Context, u32 MsgLookAheads[], int NumLookAheads, bool *pAsyncProc, int *pNumPktsFetched); +void HTCProcessCreditRpt(struct htc_target *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint); +int HTCSendSetupComplete(struct htc_target *target); +void HTCFlushRecvBuffers(struct htc_target *target); +void HTCFlushSendPkts(struct htc_target *target); #ifdef ATH_DEBUG_MODULE -void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist); -void DumpCreditDistStates(HTC_TARGET *target); -void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription); +void DumpCreditDist(struct htc_endpoint_credit_dist *pEPDist); +void DumpCreditDistStates(struct htc_target *target); +void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription); #endif -static INLINE HTC_PACKET *HTC_ALLOC_CONTROL_TX(HTC_TARGET *target) { - HTC_PACKET *pPacket = HTCAllocControlBuffer(target,&target->ControlBufferTXFreeList); +static INLINE struct htc_packet *HTC_ALLOC_CONTROL_TX(struct htc_target *target) { + struct htc_packet *pPacket = HTCAllocControlBuffer(target,&target->ControlBufferTXFreeList); if (pPacket != NULL) { /* set payload pointer area with some headroom */ pPacket->pBuffer = pPacket->pBufferStart + HTC_HDR_LENGTH; @@ -200,14 +200,14 @@ static INLINE HTC_PACKET *HTC_ALLOC_CONTROL_TX(HTC_TARGET *target) { #define HTC_PREPARE_SEND_PKT(pP,sendflags,ctrl0,ctrl1) \ { \ - A_UINT8 *pHdrBuf; \ + u8 *pHdrBuf; \ (pP)->pBuffer -= HTC_HDR_LENGTH; \ pHdrBuf = (pP)->pBuffer; \ - A_SET_UINT16_FIELD(pHdrBuf,HTC_FRAME_HDR,PayloadLen,(A_UINT16)(pP)->ActualLength); \ - A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,Flags,(sendflags)); \ - A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,EndpointID, (A_UINT8)(pP)->Endpoint); \ - A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,ControlBytes[0], (A_UINT8)(ctrl0)); \ - A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,ControlBytes[1], (A_UINT8)(ctrl1)); \ + A_SET_UINT16_FIELD(pHdrBuf,struct htc_frame_hdr,PayloadLen,(u16)(pP)->ActualLength); \ + A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,Flags,(sendflags)); \ + A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,EndpointID, (u8)(pP)->Endpoint); \ + A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,ControlBytes[0], (u8)(ctrl0)); \ + A_SET_UINT8_FIELD(pHdrBuf,struct htc_frame_hdr,ControlBytes[1], (u8)(ctrl1)); \ } #define HTC_UNPREPARE_SEND_PKT(pP) \ diff --git a/drivers/staging/ath6kl/htc2/htc_recv.c b/drivers/staging/ath6kl/htc2/htc_recv.c index 3503657..c208801 100644 --- a/drivers/staging/ath6kl/htc2/htc_recv.c +++ b/drivers/staging/ath6kl/htc2/htc_recv.c @@ -50,8 +50,8 @@ #define HTC_RX_STAT_PROFILE(t,ep,lookAhead) #endif -static void DoRecvCompletion(HTC_ENDPOINT *pEndpoint, - HTC_PACKET_QUEUE *pQueueToIndicate) +static void DoRecvCompletion(struct htc_endpoint *pEndpoint, + struct htc_packet_queue *pQueueToIndicate) { do { @@ -69,7 +69,7 @@ static void DoRecvCompletion(HTC_ENDPOINT *pEndpoint, pQueueToIndicate); INIT_HTC_PACKET_QUEUE(pQueueToIndicate); } else { - HTC_PACKET *pPacket; + struct htc_packet *pPacket; /* using legacy EpRecv */ do { pPacket = HTC_PACKET_DEQUEUE(pQueueToIndicate); @@ -79,23 +79,23 @@ static void DoRecvCompletion(HTC_ENDPOINT *pEndpoint, } while (!HTC_QUEUE_EMPTY(pQueueToIndicate)); } - } while (FALSE); + } while (false); } -static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, - A_UINT8 *pBuffer, +static INLINE int HTCProcessTrailer(struct htc_target *target, + u8 *pBuffer, int Length, - A_UINT32 *pNextLookAheads, + u32 *pNextLookAheads, int *pNumLookAheads, HTC_ENDPOINT_ID FromEndpoint) { HTC_RECORD_HDR *pRecord; - A_UINT8 *pRecordBuf; + u8 *pRecordBuf; HTC_LOOKAHEAD_REPORT *pLookAhead; - A_UINT8 *pOrigBuffer; + u8 *pOrigBuffer; int origLength; - A_STATUS status; + int status; AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessTrailer (length:%d) \n", Length)); @@ -105,7 +105,7 @@ static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, pOrigBuffer = pBuffer; origLength = Length; - status = A_OK; + status = 0; while (Length > 0) { @@ -149,14 +149,14 @@ static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, pLookAhead->PostValid)); /* look ahead bytes are valid, copy them over */ - ((A_UINT8 *)(&pNextLookAheads[0]))[0] = pLookAhead->LookAhead[0]; - ((A_UINT8 *)(&pNextLookAheads[0]))[1] = pLookAhead->LookAhead[1]; - ((A_UINT8 *)(&pNextLookAheads[0]))[2] = pLookAhead->LookAhead[2]; - ((A_UINT8 *)(&pNextLookAheads[0]))[3] = pLookAhead->LookAhead[3]; + ((u8 *)(&pNextLookAheads[0]))[0] = pLookAhead->LookAhead[0]; + ((u8 *)(&pNextLookAheads[0]))[1] = pLookAhead->LookAhead[1]; + ((u8 *)(&pNextLookAheads[0]))[2] = pLookAhead->LookAhead[2]; + ((u8 *)(&pNextLookAheads[0]))[3] = pLookAhead->LookAhead[3]; #ifdef ATH_DEBUG_MODULE if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { - DebugDumpBytes((A_UINT8 *)pNextLookAheads,4,"Next Look Ahead"); + DebugDumpBytes((u8 *)pNextLookAheads,4,"Next Look Ahead"); } #endif /* just one normal lookahead */ @@ -182,16 +182,16 @@ static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, HTC_HOST_MAX_MSG_PER_BUNDLE) { /* this should never happen, the target restricts the number * of messages per bundle configured by the host */ - A_ASSERT(FALSE); + A_ASSERT(false); status = A_EPROTO; break; } for (i = 0; i < (int)(pRecord->Length / (sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT))); i++) { - ((A_UINT8 *)(&pNextLookAheads[i]))[0] = pBundledLookAheadRpt->LookAhead[0]; - ((A_UINT8 *)(&pNextLookAheads[i]))[1] = pBundledLookAheadRpt->LookAhead[1]; - ((A_UINT8 *)(&pNextLookAheads[i]))[2] = pBundledLookAheadRpt->LookAhead[2]; - ((A_UINT8 *)(&pNextLookAheads[i]))[3] = pBundledLookAheadRpt->LookAhead[3]; + ((u8 *)(&pNextLookAheads[i]))[0] = pBundledLookAheadRpt->LookAhead[0]; + ((u8 *)(&pNextLookAheads[i]))[1] = pBundledLookAheadRpt->LookAhead[1]; + ((u8 *)(&pNextLookAheads[i]))[2] = pBundledLookAheadRpt->LookAhead[2]; + ((u8 *)(&pNextLookAheads[i]))[3] = pBundledLookAheadRpt->LookAhead[3]; pBundledLookAheadRpt++; } @@ -204,7 +204,7 @@ static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, break; } - if (A_FAILED(status)) { + if (status) { break; } @@ -214,7 +214,7 @@ static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, } #ifdef ATH_DEBUG_MODULE - if (A_FAILED(status)) { + if (status) { DebugDumpBytes(pOrigBuffer,origLength,"BAD Recv Trailer"); } #endif @@ -226,16 +226,16 @@ static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, /* process a received message (i.e. strip off header, process any trailer data) * note : locks must be released when this function is called */ -static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, - HTC_PACKET *pPacket, - A_UINT32 *pNextLookAheads, +static int HTCProcessRecvHeader(struct htc_target *target, + struct htc_packet *pPacket, + u32 *pNextLookAheads, int *pNumLookAheads) { - A_UINT8 temp; - A_UINT8 *pBuf; - A_STATUS status = A_OK; - A_UINT16 payloadLen; - A_UINT32 lookAhead; + u8 temp; + u8 *pBuf; + int status = 0; + u16 payloadLen; + u32 lookAhead; pBuf = pPacket->pBuffer; @@ -252,12 +252,12 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, do { /* note, we cannot assume the alignment of pBuffer, so we use the safe macros to * retrieve 16 bit fields */ - payloadLen = A_GET_UINT16_FIELD(pBuf, HTC_FRAME_HDR, PayloadLen); + payloadLen = A_GET_UINT16_FIELD(pBuf, struct htc_frame_hdr, PayloadLen); - ((A_UINT8 *)&lookAhead)[0] = pBuf[0]; - ((A_UINT8 *)&lookAhead)[1] = pBuf[1]; - ((A_UINT8 *)&lookAhead)[2] = pBuf[2]; - ((A_UINT8 *)&lookAhead)[3] = pBuf[3]; + ((u8 *)&lookAhead)[0] = pBuf[0]; + ((u8 *)&lookAhead)[1] = pBuf[1]; + ((u8 *)&lookAhead)[2] = pBuf[2]; + ((u8 *)&lookAhead)[3] = pBuf[3]; if (pPacket->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_REFRESH_HDR) { /* refresh expected hdr, since this was unknown at the time we grabbed the packets @@ -277,10 +277,10 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, break; } - if (pPacket->Endpoint != A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, EndpointID)) { + if (pPacket->Endpoint != A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, EndpointID)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Refreshed HDR endpoint (%d) does not match expected endpoint (%d) \n", - A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, EndpointID), pPacket->Endpoint)); + A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, EndpointID), pPacket->Endpoint)); status = A_EPROTO; break; } @@ -293,10 +293,10 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, ("HTCProcessRecvHeader, lookahead mismatch! (pPkt:0x%lX flags:0x%X) \n", (unsigned long)pPacket, pPacket->PktInfo.AsRx.HTCRxFlags)); #ifdef ATH_DEBUG_MODULE - DebugDumpBytes((A_UINT8 *)&pPacket->PktInfo.AsRx.ExpectedHdr,4,"Expected Message LookAhead"); - DebugDumpBytes(pBuf,sizeof(HTC_FRAME_HDR),"Current Frame Header"); + DebugDumpBytes((u8 *)&pPacket->PktInfo.AsRx.ExpectedHdr,4,"Expected Message LookAhead"); + DebugDumpBytes(pBuf,sizeof(struct htc_frame_hdr),"Current Frame Header"); #ifdef HTC_CAPTURE_LAST_FRAME - DebugDumpBytes((A_UINT8 *)&target->LastFrameHdr,sizeof(HTC_FRAME_HDR),"Last Frame Header"); + DebugDumpBytes((u8 *)&target->LastFrameHdr,sizeof(struct htc_frame_hdr),"Last Frame Header"); if (target->LastTrailerLength != 0) { DebugDumpBytes(target->LastTrailer, target->LastTrailerLength, @@ -309,13 +309,13 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, } /* get flags */ - temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, Flags); + temp = A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, Flags); if (temp & HTC_FLAGS_RECV_TRAILER) { /* this packet has a trailer */ /* extract the trailer length in control byte 0 */ - temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, ControlBytes[0]); + temp = A_GET_UINT8_FIELD(pBuf, struct htc_frame_hdr, ControlBytes[0]); if ((temp < sizeof(HTC_RECORD_HDR)) || (temp > payloadLen)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, @@ -341,12 +341,12 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, pNumLookAheads, pPacket->Endpoint); - if (A_FAILED(status)) { + if (status) { break; } #ifdef HTC_CAPTURE_LAST_FRAME - A_MEMCPY(target->LastTrailer, (pBuf + HTC_HDR_LENGTH + payloadLen - temp), temp); + memcpy(target->LastTrailer, (pBuf + HTC_HDR_LENGTH + payloadLen - temp), temp); target->LastTrailerLength = temp; #endif /* trim length by trailer bytes */ @@ -363,16 +363,16 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, pPacket->pBuffer += HTC_HDR_LENGTH; pPacket->ActualLength -= HTC_HDR_LENGTH; - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { /* dump the whole packet */ #ifdef ATH_DEBUG_MODULE DebugDumpBytes(pBuf,pPacket->ActualLength < 256 ? pPacket->ActualLength : 256 ,"BAD HTC Recv PKT"); #endif } else { #ifdef HTC_CAPTURE_LAST_FRAME - A_MEMCPY(&target->LastFrameHdr,pBuf,sizeof(HTC_FRAME_HDR)); + memcpy(&target->LastFrameHdr,pBuf,sizeof(struct htc_frame_hdr)); #endif if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { if (pPacket->ActualLength > 0) { @@ -385,14 +385,14 @@ static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, return status; } -static INLINE void HTCAsyncRecvCheckMorePackets(HTC_TARGET *target, - A_UINT32 NextLookAheads[], +static INLINE void HTCAsyncRecvCheckMorePackets(struct htc_target *target, + u32 NextLookAheads[], int NumLookAheads, - A_BOOL CheckMoreMsgs) + bool CheckMoreMsgs) { /* was there a lookahead for the next packet? */ if (NumLookAheads > 0) { - A_STATUS nextStatus; + int nextStatus; int fetched = 0; AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("HTCAsyncRecvCheckMorePackets - num lookaheads were non-zero : %d \n", @@ -405,12 +405,12 @@ static INLINE void HTCAsyncRecvCheckMorePackets(HTC_TARGET *target, AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Next look ahead from recv header was INVALID\n")); #ifdef ATH_DEBUG_MODULE - DebugDumpBytes((A_UINT8 *)NextLookAheads, - NumLookAheads * (sizeof(A_UINT32)), + DebugDumpBytes((u8 *)NextLookAheads, + NumLookAheads * (sizeof(u32)), "BAD lookaheads from lookahead report"); #endif } - if (A_SUCCESS(nextStatus) && !fetched) { + if (!nextStatus && !fetched) { /* we could not fetch any more packets due to resources */ DevAsyncIrqProcessComplete(&target->Device); } @@ -432,9 +432,9 @@ static INLINE void HTCAsyncRecvCheckMorePackets(HTC_TARGET *target, } /* unload the recv completion queue */ -static INLINE void DrainRecvIndicationQueue(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint) +static INLINE void DrainRecvIndicationQueue(struct htc_target *target, struct htc_endpoint *pEndpoint) { - HTC_PACKET_QUEUE recvCompletions; + struct htc_packet_queue recvCompletions; AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+DrainRecvIndicationQueue \n")); @@ -454,7 +454,7 @@ static INLINE void DrainRecvIndicationQueue(HTC_TARGET *target, HTC_ENDPOINT *pE /******* at this point only 1 thread may enter ******/ - while (TRUE) { + while (true) { /* transfer items from main recv queue to the local one so we can release the lock */ HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(&recvCompletions, &pEndpoint->RecvIndicationQueue); @@ -496,11 +496,11 @@ static INLINE void DrainRecvIndicationQueue(HTC_TARGET *target, HTC_ENDPOINT *pE (P)->PktInfo.AsRx.IndicationFlags |= HTC_RX_FLAGS_INDICATE_MORE_PKTS; /* note: this function can be called with the RX lock held */ -static INLINE void SetRxPacketIndicationFlags(A_UINT32 LookAhead, - HTC_ENDPOINT *pEndpoint, - HTC_PACKET *pPacket) +static INLINE void SetRxPacketIndicationFlags(u32 LookAhead, + struct htc_endpoint *pEndpoint, + struct htc_packet *pPacket) { - HTC_FRAME_HDR *pHdr = (HTC_FRAME_HDR *)&LookAhead; + struct htc_frame_hdr *pHdr = (struct htc_frame_hdr *)&LookAhead; /* check to see if the "next" packet is from the same endpoint of the completing packet */ if (pHdr->EndpointID == pPacket->Endpoint) { @@ -515,14 +515,14 @@ static INLINE void SetRxPacketIndicationFlags(A_UINT32 LookAhead, /* asynchronous completion handler for recv packet fetching, when the device layer * completes a read request, it will call this completion handler */ -void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) +void HTCRecvCompleteHandler(void *Context, struct htc_packet *pPacket) { - HTC_TARGET *target = (HTC_TARGET *)Context; - HTC_ENDPOINT *pEndpoint; - A_UINT32 nextLookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; + struct htc_target *target = (struct htc_target *)Context; + struct htc_endpoint *pEndpoint; + u32 nextLookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; int numLookAheads = 0; - A_STATUS status; - A_BOOL checkMorePkts = TRUE; + int status; + bool checkMorePkts = true; AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCRecvCompleteHandler (pkt:0x%lX, status:%d, ep:%d) \n", (unsigned long)pPacket, pPacket->Status, pPacket->Endpoint)); @@ -537,7 +537,7 @@ void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) do { - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCRecvCompleteHandler: request failed (status:%d, ep:%d) \n", pPacket->Status, pPacket->Endpoint)); break; @@ -545,7 +545,7 @@ void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) /* process the header for any trailer data */ status = HTCProcessRecvHeader(target,pPacket,nextLookAheads,&numLookAheads); - if (A_FAILED(status)) { + if (status) { break; } @@ -554,7 +554,7 @@ void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) * It was fetched one message at a time. There may be other asynchronous reads queued behind this one. * Do no issue another check for more packets since the last one in the series of requests * will handle it */ - checkMorePkts = FALSE; + checkMorePkts = false; } DUMP_RECV_PKT_INFO(pPacket); @@ -568,9 +568,9 @@ void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) /* check for more recv packets before indicating */ HTCAsyncRecvCheckMorePackets(target,nextLookAheads,numLookAheads,checkMorePkts); - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCRecvCompleteHandler , message fetch failed (status = %d) \n", status)); @@ -587,12 +587,12 @@ void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) /* synchronously wait for a control message from the target, * This function is used at initialization time ONLY. At init messages * on ENDPOINT 0 are expected. */ -A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPacket) +int HTCWaitforControlMessage(struct htc_target *target, struct htc_packet **ppControlPacket) { - A_STATUS status; - A_UINT32 lookAhead; - HTC_PACKET *pPacket = NULL; - HTC_FRAME_HDR *pHdr; + int status; + u32 lookAhead; + struct htc_packet *pPacket = NULL; + struct htc_frame_hdr *pHdr; AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCWaitforControlMessage \n")); @@ -605,7 +605,7 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack &lookAhead, HTC_TARGET_RESPONSE_TIMEOUT); - if (A_FAILED(status)) { + if (status) { break; } @@ -613,18 +613,18 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack ("HTCWaitforControlMessage : lookAhead : 0x%X \n", lookAhead)); /* check the lookahead */ - pHdr = (HTC_FRAME_HDR *)&lookAhead; + pHdr = (struct htc_frame_hdr *)&lookAhead; if (pHdr->EndpointID != ENDPOINT_0) { /* unexpected endpoint number, should be zero */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_EPROTO; break; } - if (A_FAILED(status)) { + if (status) { /* bad message */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_EPROTO; break; } @@ -632,7 +632,7 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack pPacket = HTC_ALLOC_CONTROL_RX(target); if (pPacket == NULL) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_NO_MEMORY; break; } @@ -642,7 +642,7 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH; if (pPacket->ActualLength > pPacket->BufferLength) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_EPROTO; break; } @@ -653,7 +653,7 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack /* get the message from the device, this will block */ status = HTCIssueRecv(target, pPacket); - if (A_FAILED(status)) { + if (status) { break; } @@ -662,7 +662,7 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack pPacket->Status = status; - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCWaitforControlMessage, HTCProcessRecvHeader failed (status = %d) \n", status)); @@ -672,9 +672,9 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack /* give the caller this control message packet, they are responsible to free */ *ppControlPacket = pPacket; - } while (FALSE); + } while (false); - if (A_FAILED(status)) { + if (status) { if (pPacket != NULL) { /* cleanup buffer on error */ HTC_FREE_CONTROL_RX(target,pPacket); @@ -686,26 +686,26 @@ A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPack return status; } -static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, - A_UINT32 LookAheads[], +static int AllocAndPrepareRxPackets(struct htc_target *target, + u32 LookAheads[], int Messages, - HTC_ENDPOINT *pEndpoint, - HTC_PACKET_QUEUE *pQueue) + struct htc_endpoint *pEndpoint, + struct htc_packet_queue *pQueue) { - A_STATUS status = A_OK; - HTC_PACKET *pPacket; - HTC_FRAME_HDR *pHdr; + int status = 0; + struct htc_packet *pPacket; + struct htc_frame_hdr *pHdr; int i,j; int numMessages; int fullLength; - A_BOOL noRecycle; + bool noRecycle; /* lock RX while we assemble the packet buffers */ LOCK_HTC_RX(target); for (i = 0; i < Messages; i++) { - pHdr = (HTC_FRAME_HDR *)&LookAheads[i]; + pHdr = (struct htc_frame_hdr *)&LookAheads[i]; if (pHdr->EndpointID >= ENDPOINT_MAX) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Endpoint in look-ahead: %d \n",pHdr->EndpointID)); @@ -724,7 +724,7 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, if (pHdr->PayloadLen > HTC_MAX_PAYLOAD_LENGTH) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Payload length %d exceeds max HTC : %d !\n", - pHdr->PayloadLen, (A_UINT32)HTC_MAX_PAYLOAD_LENGTH)); + pHdr->PayloadLen, (u32)HTC_MAX_PAYLOAD_LENGTH)); status = A_EPROTO; break; } @@ -751,7 +751,7 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, ("HTC header indicates :%d messages can be fetched as a bundle \n",numMessages)); } - fullLength = DEV_CALC_RECV_PADDED_LEN(&target->Device,pHdr->PayloadLen + sizeof(HTC_FRAME_HDR)); + fullLength = DEV_CALC_RECV_PADDED_LEN(&target->Device,pHdr->PayloadLen + sizeof(struct htc_frame_hdr)); /* get packet buffers for each message, if there was a bundle detected in the header, * use pHdr as a template to fetch all packets in the bundle */ @@ -759,11 +759,11 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, /* reset flag, any packets allocated using the RecvAlloc() API cannot be recycled on cleanup, * they must be explicitly returned */ - noRecycle = FALSE; + noRecycle = false; if (pEndpoint->EpCallBacks.EpRecvAlloc != NULL) { UNLOCK_HTC_RX(target); - noRecycle = TRUE; + noRecycle = true; /* user is using a per-packet allocation callback */ pPacket = pEndpoint->EpCallBacks.EpRecvAlloc(pEndpoint->EpCallBacks.pContext, pEndpoint->Id, @@ -776,7 +776,7 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, INC_HTC_EP_STAT(pEndpoint,RxAllocThreshBytes,pHdr->PayloadLen); /* threshold was hit, call the special recv allocation callback */ UNLOCK_HTC_RX(target); - noRecycle = TRUE; + noRecycle = true; /* user wants to allocate packets above a certain threshold */ pPacket = pEndpoint->EpCallBacks.EpRecvAllocThresh(pEndpoint->EpCallBacks.pContext, pEndpoint->Id, @@ -816,7 +816,7 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, /* clear flags */ pPacket->PktInfo.AsRx.HTCRxFlags = 0; pPacket->PktInfo.AsRx.IndicationFlags = 0; - pPacket->Status = A_OK; + pPacket->Status = 0; if (noRecycle) { /* flag that these packets cannot be recycled, they have to be returned to the @@ -832,7 +832,7 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, } /* make sure this message can fit in the endpoint buffer */ - if ((A_UINT32)fullLength > pPacket->BufferLength) { + if ((u32)fullLength > pPacket->BufferLength) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Payload Length Error : header reports payload of: %d (%d) endpoint buffer size: %d \n", pHdr->PayloadLen, fullLength, pPacket->BufferLength)); @@ -856,10 +856,10 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH; } - if (A_FAILED(status)) { + if (status) { if (A_NO_RESOURCE == status) { /* this is actually okay */ - status = A_OK; + status = 0; } break; } @@ -868,7 +868,7 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, UNLOCK_HTC_RX(target); - if (A_FAILED(status)) { + if (status) { while (!HTC_QUEUE_EMPTY(pQueue)) { pPacket = HTC_PACKET_DEQUEUE(pQueue); /* recycle all allocated packets */ @@ -879,37 +879,37 @@ static A_STATUS AllocAndPrepareRxPackets(HTC_TARGET *target, return status; } -static void HTCAsyncRecvScatterCompletion(HIF_SCATTER_REQ *pScatterReq) +static void HTCAsyncRecvScatterCompletion(struct hif_scatter_req *pScatterReq) { int i; - HTC_PACKET *pPacket; - HTC_ENDPOINT *pEndpoint; - A_UINT32 lookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; + struct htc_packet *pPacket; + struct htc_endpoint *pEndpoint; + u32 lookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; int numLookAheads = 0; - HTC_TARGET *target = (HTC_TARGET *)pScatterReq->Context; - A_STATUS status; - A_BOOL partialBundle = FALSE; - HTC_PACKET_QUEUE localRecvQueue; - A_BOOL procError = FALSE; + struct htc_target *target = (struct htc_target *)pScatterReq->Context; + int status; + bool partialBundle = false; + struct htc_packet_queue localRecvQueue; + bool procError = false; AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCAsyncRecvScatterCompletion TotLen: %d Entries: %d\n", pScatterReq->TotalLength, pScatterReq->ValidScatterEntries)); A_ASSERT(!IS_DEV_IRQ_PROC_SYNC_MODE(&target->Device)); - if (A_FAILED(pScatterReq->CompletionStatus)) { + if (pScatterReq->CompletionStatus) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** Recv Scatter Request Failed: %d \n",pScatterReq->CompletionStatus)); } if (pScatterReq->CallerFlags & HTC_SCATTER_REQ_FLAGS_PARTIAL_BUNDLE) { - partialBundle = TRUE; + partialBundle = true; } DEV_FINISH_SCATTER_OPERATION(pScatterReq); INIT_HTC_PACKET_QUEUE(&localRecvQueue); - pPacket = (HTC_PACKET *)pScatterReq->ScatterList[0].pCallerContexts[0]; + pPacket = (struct htc_packet *)pScatterReq->ScatterList[0].pCallerContexts[0]; /* note: all packets in a scatter req are for the same endpoint ! */ pEndpoint = &target->EndPoint[pPacket->Endpoint]; @@ -917,20 +917,20 @@ static void HTCAsyncRecvScatterCompletion(HIF_SCATTER_REQ *pScatterReq) /* **** NOTE: DO NOT HOLD ANY LOCKS here, HTCProcessRecvHeader can take the TX lock * as it processes credit reports */ for (i = 0; i < pScatterReq->ValidScatterEntries; i++) { - pPacket = (HTC_PACKET *)pScatterReq->ScatterList[i].pCallerContexts[0]; + pPacket = (struct htc_packet *)pScatterReq->ScatterList[i].pCallerContexts[0]; A_ASSERT(pPacket != NULL); /* reset count, we are only interested in the look ahead in the last packet when we * break out of this loop */ numLookAheads = 0; - if (A_SUCCESS(pScatterReq->CompletionStatus)) { + if (!pScatterReq->CompletionStatus) { /* process header for each of the recv packets */ status = HTCProcessRecvHeader(target,pPacket,lookAheads,&numLookAheads); } else { status = A_ERROR; } - if (A_SUCCESS(status)) { + if (!status) { #ifdef HTC_EP_STAT_PROFILING LOCK_HTC_RX(target); HTC_RX_STAT_PROFILE(target,pEndpoint,numLookAheads); @@ -956,7 +956,7 @@ static void HTCAsyncRecvScatterCompletion(HIF_SCATTER_REQ *pScatterReq) /* recycle failed recv */ HTC_RECYCLE_RX_PKT(target, pPacket, pEndpoint); /* set flag and continue processing the remaining scatter entries */ - procError = TRUE; + procError = true; } } @@ -975,7 +975,7 @@ static void HTCAsyncRecvScatterCompletion(HIF_SCATTER_REQ *pScatterReq) HTCAsyncRecvCheckMorePackets(target, lookAheads, numLookAheads, - partialBundle ? FALSE : TRUE); + partialBundle ? false : true); } /* now drain the indication queue */ @@ -984,18 +984,18 @@ static void HTCAsyncRecvScatterCompletion(HIF_SCATTER_REQ *pScatterReq) AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCAsyncRecvScatterCompletion \n")); } -static A_STATUS HTCIssueRecvPacketBundle(HTC_TARGET *target, - HTC_PACKET_QUEUE *pRecvPktQueue, - HTC_PACKET_QUEUE *pSyncCompletionQueue, +static int HTCIssueRecvPacketBundle(struct htc_target *target, + struct htc_packet_queue *pRecvPktQueue, + struct htc_packet_queue *pSyncCompletionQueue, int *pNumPacketsFetched, - A_BOOL PartialBundle) + bool PartialBundle) { - A_STATUS status = A_OK; - HIF_SCATTER_REQ *pScatterReq; + int status = 0; + struct hif_scatter_req *pScatterReq; int i, totalLength; int pktsToScatter; - HTC_PACKET *pPacket; - A_BOOL asyncMode = (pSyncCompletionQueue == NULL) ? TRUE : FALSE; + struct htc_packet *pPacket; + bool asyncMode = (pSyncCompletionQueue == NULL) ? true : false; int scatterSpaceRemaining = DEV_GET_MAX_BUNDLE_RECV_LENGTH(&target->Device); pktsToScatter = HTC_PACKET_QUEUE_DEPTH(pRecvPktQueue); @@ -1004,7 +1004,7 @@ static A_STATUS HTCIssueRecvPacketBundle(HTC_TARGET *target, if ((HTC_PACKET_QUEUE_DEPTH(pRecvPktQueue) - pktsToScatter) > 0) { /* we were forced to split this bundle receive operation * all packets in this partial bundle must have their lookaheads ignored */ - PartialBundle = TRUE; + PartialBundle = true; /* this would only happen if the target ignored our max bundle limit */ AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("HTCIssueRecvPacketBundle : partial bundle detected num:%d , %d \n", @@ -1085,7 +1085,7 @@ static A_STATUS HTCIssueRecvPacketBundle(HTC_TARGET *target, status = DevSubmitScatterRequest(&target->Device, pScatterReq, DEV_SCATTER_READ, asyncMode); - if (A_SUCCESS(status)) { + if (!status) { *pNumPacketsFetched = i; } @@ -1094,7 +1094,7 @@ static A_STATUS HTCIssueRecvPacketBundle(HTC_TARGET *target, DEV_FREE_SCATTER_REQ(&target->Device, pScatterReq); } - } while (FALSE); + } while (false); AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCIssueRecvPacketBundle (status:%d) (fetched:%d) \n", status,*pNumPacketsFetched)); @@ -1102,7 +1102,7 @@ static A_STATUS HTCIssueRecvPacketBundle(HTC_TARGET *target, return status; } -static INLINE void CheckRecvWaterMark(HTC_ENDPOINT *pEndpoint) +static INLINE void CheckRecvWaterMark(struct htc_endpoint *pEndpoint) { /* see if endpoint is using a refill watermark * ** no need to use a lock here, since we are only inspecting... @@ -1117,17 +1117,17 @@ static INLINE void CheckRecvWaterMark(HTC_ENDPOINT *pEndpoint) } /* callback when device layer or lookahead report parsing detects a pending message */ -A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], int NumLookAheads, A_BOOL *pAsyncProc, int *pNumPktsFetched) +int HTCRecvMessagePendingHandler(void *Context, u32 MsgLookAheads[], int NumLookAheads, bool *pAsyncProc, int *pNumPktsFetched) { - HTC_TARGET *target = (HTC_TARGET *)Context; - A_STATUS status = A_OK; - HTC_PACKET *pPacket; - HTC_ENDPOINT *pEndpoint; - A_BOOL asyncProc = FALSE; - A_UINT32 lookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; + struct htc_target *target = (struct htc_target *)Context; + int status = 0; + struct htc_packet *pPacket; + struct htc_endpoint *pEndpoint; + bool asyncProc = false; + u32 lookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; int pktsFetched; - HTC_PACKET_QUEUE recvPktQueue, syncCompletedPktsQueue; - A_BOOL partialBundle; + struct htc_packet_queue recvPktQueue, syncCompletedPktsQueue; + bool partialBundle; HTC_ENDPOINT_ID id; int totalFetched = 0; @@ -1141,7 +1141,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i /* We use async mode to get the packets if the device layer supports it. * The device layer interfaces with HIF in which HIF may have restrictions on * how interrupts are processed */ - asyncProc = TRUE; + asyncProc = true; } if (pAsyncProc != NULL) { @@ -1150,14 +1150,14 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i } if (NumLookAheads > HTC_HOST_MAX_MSG_PER_BUNDLE) { - A_ASSERT(FALSE); + A_ASSERT(false); return A_EPROTO; } /* on first entry copy the lookaheads into our temp array for processing */ - A_MEMCPY(lookAheads, MsgLookAheads, (sizeof(A_UINT32)) * NumLookAheads); + memcpy(lookAheads, MsgLookAheads, (sizeof(u32)) * NumLookAheads); - while (TRUE) { + while (true) { /* reset packets queues */ INIT_HTC_PACKET_QUEUE(&recvPktQueue); @@ -1165,12 +1165,12 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i if (NumLookAheads > HTC_HOST_MAX_MSG_PER_BUNDLE) { status = A_EPROTO; - A_ASSERT(FALSE); + A_ASSERT(false); break; } /* first lookahead sets the expected endpoint IDs for all packets in a bundle */ - id = ((HTC_FRAME_HDR *)&lookAheads[0])->EndpointID; + id = ((struct htc_frame_hdr *)&lookAheads[0])->EndpointID; pEndpoint = &target->EndPoint[id]; if (id >= ENDPOINT_MAX) { @@ -1186,7 +1186,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i NumLookAheads, pEndpoint, &recvPktQueue); - if (A_FAILED(status)) { + if (status) { break; } @@ -1200,7 +1200,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i /* we've got packet buffers for all we can currently fetch, * this count is not valid anymore */ NumLookAheads = 0; - partialBundle = FALSE; + partialBundle = false; /* now go fetch the list of HTC packets */ while (!HTC_QUEUE_EMPTY(&recvPktQueue)) { @@ -1214,14 +1214,14 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i asyncProc ? NULL : &syncCompletedPktsQueue, &pktsFetched, partialBundle); - if (A_FAILED(status)) { + if (status) { break; } if (HTC_PACKET_QUEUE_DEPTH(&recvPktQueue) != 0) { /* we couldn't fetch all packets at one time, this creates a broken * bundle */ - partialBundle = TRUE; + partialBundle = true; } } @@ -1248,7 +1248,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i /* go fetch the packet */ status = HTCIssueRecv(target, pPacket); - if (A_FAILED(status)) { + if (status) { break; } @@ -1261,7 +1261,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i } - if (A_SUCCESS(status)) { + if (!status) { CheckRecvWaterMark(pEndpoint); } @@ -1283,7 +1283,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i /* unload sync completion queue */ while (!HTC_QUEUE_EMPTY(&syncCompletedPktsQueue)) { - HTC_PACKET_QUEUE container; + struct htc_packet_queue container; pPacket = HTC_PACKET_DEQUEUE(&syncCompletedPktsQueue); A_ASSERT(pPacket != NULL); @@ -1295,7 +1295,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i /* process header for each of the recv packets * note: the lookahead of the last packet is useful for us to continue in this loop */ status = HTCProcessRecvHeader(target,pPacket,lookAheads,&NumLookAheads); - if (A_FAILED(status)) { + if (status) { break; } @@ -1317,7 +1317,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i DO_RCV_COMPLETION(pEndpoint,&container); } - if (A_FAILED(status)) { + if (status) { break; } @@ -1346,7 +1346,7 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i REF_IRQ_STATUS_RECHECK(&target->Device); } - if (A_FAILED(status)) { + if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to get pending recv messages (%d) \n",status)); /* cleanup any packets we allocated but didn't use to actually fetch any packets */ @@ -1385,18 +1385,18 @@ A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[], i return status; } -A_STATUS HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, HTC_PACKET_QUEUE *pPktQueue) +int HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, struct htc_packet_queue *pPktQueue) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - HTC_ENDPOINT *pEndpoint; - A_BOOL unblockRecv = FALSE; - A_STATUS status = A_OK; - HTC_PACKET *pFirstPacket; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_endpoint *pEndpoint; + bool unblockRecv = false; + int status = 0; + struct htc_packet *pFirstPacket; pFirstPacket = HTC_GET_PKT_AT_HEAD(pPktQueue); if (NULL == pFirstPacket) { - A_ASSERT(FALSE); + A_ASSERT(false); return A_EINVAL; } @@ -1415,7 +1415,7 @@ A_STATUS HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, HTC_PACKET_QUEUE *pPktQu LOCK_HTC_RX(target); if (HTC_STOPPING(target)) { - HTC_PACKET *pPacket; + struct htc_packet *pPacket; UNLOCK_HTC_RX(target); @@ -1438,7 +1438,7 @@ A_STATUS HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, HTC_PACKET_QUEUE *pPktQu target->EpWaitingForBuffers)); target->RecvStateFlags &= ~HTC_RECV_WAIT_BUFFERS; target->EpWaitingForBuffers = ENDPOINT_MAX; - unblockRecv = TRUE; + unblockRecv = true; } } @@ -1449,23 +1449,23 @@ A_STATUS HTCAddReceivePktMultiple(HTC_HANDLE HTCHandle, HTC_PACKET_QUEUE *pPktQu DevEnableRecv(&target->Device,DEV_ENABLE_RECV_SYNC); } - } while (FALSE); + } while (false); return status; } /* Makes a buffer available to the HTC module */ -A_STATUS HTCAddReceivePkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket) +int HTCAddReceivePkt(HTC_HANDLE HTCHandle, struct htc_packet *pPacket) { - HTC_PACKET_QUEUE queue; + struct htc_packet_queue queue; INIT_HTC_PACKET_QUEUE_AND_ADD(&queue,pPacket); return HTCAddReceivePktMultiple(HTCHandle, &queue); } void HTCUnblockRecv(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - A_BOOL unblockRecv = FALSE; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + bool unblockRecv = false; LOCK_HTC_RX(target); @@ -1475,7 +1475,7 @@ void HTCUnblockRecv(HTC_HANDLE HTCHandle) target->EpWaitingForBuffers)); target->RecvStateFlags &= ~HTC_RECV_WAIT_BUFFERS; target->EpWaitingForBuffers = ENDPOINT_MAX; - unblockRecv = TRUE; + unblockRecv = true; } UNLOCK_HTC_RX(target); @@ -1486,10 +1486,10 @@ void HTCUnblockRecv(HTC_HANDLE HTCHandle) } } -static void HTCFlushRxQueue(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_PACKET_QUEUE *pQueue) +static void HTCFlushRxQueue(struct htc_target *target, struct htc_endpoint *pEndpoint, struct htc_packet_queue *pQueue) { - HTC_PACKET *pPacket; - HTC_PACKET_QUEUE container; + struct htc_packet *pPacket; + struct htc_packet_queue container; LOCK_HTC_RX(target); @@ -1512,7 +1512,7 @@ static void HTCFlushRxQueue(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_PAC UNLOCK_HTC_RX(target); } -static void HTCFlushEndpointRX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint) +static void HTCFlushEndpointRX(struct htc_target *target, struct htc_endpoint *pEndpoint) { /* flush any recv indications not already made */ HTCFlushRxQueue(target,pEndpoint,&pEndpoint->RecvIndicationQueue); @@ -1520,9 +1520,9 @@ static void HTCFlushEndpointRX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint) HTCFlushRxQueue(target,pEndpoint,&pEndpoint->RxBuffers); } -void HTCFlushRecvBuffers(HTC_TARGET *target) +void HTCFlushRecvBuffers(struct htc_target *target) { - HTC_ENDPOINT *pEndpoint; + struct htc_endpoint *pEndpoint; int i; for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) { @@ -1538,7 +1538,7 @@ void HTCFlushRecvBuffers(HTC_TARGET *target) void HTCEnableRecv(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); if (!HTC_STOPPING(target)) { /* re-enable */ @@ -1548,7 +1548,7 @@ void HTCEnableRecv(HTC_HANDLE HTCHandle) void HTCDisableRecv(HTC_HANDLE HTCHandle) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); if (!HTC_STOPPING(target)) { /* disable */ @@ -1559,16 +1559,16 @@ void HTCDisableRecv(HTC_HANDLE HTCHandle) int HTCGetNumRecvBuffers(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); return HTC_PACKET_QUEUE_DEPTH(&(target->EndPoint[Endpoint].RxBuffers)); } -A_STATUS HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, - A_UINT32 TimeoutInMs, - A_BOOL *pbIsRecvPending) +int HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, + u32 TimeoutInMs, + bool *pbIsRecvPending) { - A_STATUS status = A_OK; - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + int status = 0; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); status = DevWaitForPendingRecv(&target->Device, TimeoutInMs, diff --git a/drivers/staging/ath6kl/htc2/htc_send.c b/drivers/staging/ath6kl/htc2/htc_send.c index bc7ee78..6f4050a 100644 --- a/drivers/staging/ath6kl/htc2/htc_send.c +++ b/drivers/staging/ath6kl/htc2/htc_send.c @@ -43,8 +43,8 @@ typedef enum _HTC_SEND_QUEUE_RESULT { (reason)); \ } -static void DoSendCompletion(HTC_ENDPOINT *pEndpoint, - HTC_PACKET_QUEUE *pQueueToIndicate) +static void DoSendCompletion(struct htc_endpoint *pEndpoint, + struct htc_packet_queue *pQueueToIndicate) { do { @@ -62,7 +62,7 @@ static void DoSendCompletion(HTC_ENDPOINT *pEndpoint, /* all packets are now owned by the callback, reset queue to be safe */ INIT_HTC_PACKET_QUEUE(pQueueToIndicate); } else { - HTC_PACKET *pPacket; + struct htc_packet *pPacket; /* using legacy EpTxComplete */ do { pPacket = HTC_PACKET_DEQUEUE(pQueueToIndicate); @@ -72,16 +72,16 @@ static void DoSendCompletion(HTC_ENDPOINT *pEndpoint, } while (!HTC_QUEUE_EMPTY(pQueueToIndicate)); } - } while (FALSE); + } while (false); } /* do final completion on sent packet */ -static INLINE void CompleteSentPacket(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_PACKET *pPacket) +static INLINE void CompleteSentPacket(struct htc_target *target, struct htc_endpoint *pEndpoint, struct htc_packet *pPacket) { pPacket->Completion = NULL; - if (A_FAILED(pPacket->Status)) { + if (pPacket->Status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("CompleteSentPacket: request failed (status:%d, ep:%d, length:%d creds:%d) \n", pPacket->Status, pPacket->Endpoint, pPacket->ActualLength, pPacket->PktInfo.AsTx.CreditsUsed)); @@ -101,11 +101,11 @@ static INLINE void CompleteSentPacket(HTC_TARGET *target, HTC_ENDPOINT *pEndpoin /* our internal send packet completion handler when packets are submited to the AR6K device * layer */ -static void HTCSendPktCompletionHandler(void *Context, HTC_PACKET *pPacket) +static void HTCSendPktCompletionHandler(void *Context, struct htc_packet *pPacket) { - HTC_TARGET *target = (HTC_TARGET *)Context; - HTC_ENDPOINT *pEndpoint = &target->EndPoint[pPacket->Endpoint]; - HTC_PACKET_QUEUE container; + struct htc_target *target = (struct htc_target *)Context; + struct htc_endpoint *pEndpoint = &target->EndPoint[pPacket->Endpoint]; + struct htc_packet_queue container; CompleteSentPacket(target,pEndpoint,pPacket); INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); @@ -113,19 +113,19 @@ static void HTCSendPktCompletionHandler(void *Context, HTC_PACKET *pPacket) DO_EP_TX_COMPLETION(pEndpoint,&container); } -A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket) +int HTCIssueSend(struct htc_target *target, struct htc_packet *pPacket) { - A_STATUS status; - A_BOOL sync = FALSE; + int status; + bool sync = false; if (pPacket->Completion == NULL) { /* mark that this request was synchronously issued */ - sync = TRUE; + sync = true; } AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+-HTCIssueSend: transmit length : %d (%s) \n", - pPacket->ActualLength + (A_UINT32)HTC_HDR_LENGTH, + pPacket->ActualLength + (u32)HTC_HDR_LENGTH, sync ? "SYNC" : "ASYNC" )); /* send message to device */ @@ -146,21 +146,21 @@ A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket) } /* get HTC send packets from the TX queue on an endpoint */ -static INLINE void GetHTCSendPackets(HTC_TARGET *target, - HTC_ENDPOINT *pEndpoint, - HTC_PACKET_QUEUE *pQueue) +static INLINE void GetHTCSendPackets(struct htc_target *target, + struct htc_endpoint *pEndpoint, + struct htc_packet_queue *pQueue) { int creditsRequired; int remainder; - A_UINT8 sendFlags; - HTC_PACKET *pPacket; + u8 sendFlags; + struct htc_packet *pPacket; unsigned int transferLength; /****** NOTE : the TX lock is held when this function is called *****************/ AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+GetHTCSendPackets \n")); /* loop until we can grab as many packets out of the queue as we can */ - while (TRUE) { + while (true) { sendFlags = 0; /* get packet at head, but don't remove it */ @@ -264,14 +264,14 @@ static INLINE void GetHTCSendPackets(HTC_TARGET *target, } -static void HTCAsyncSendScatterCompletion(HIF_SCATTER_REQ *pScatterReq) +static void HTCAsyncSendScatterCompletion(struct hif_scatter_req *pScatterReq) { int i; - HTC_PACKET *pPacket; - HTC_ENDPOINT *pEndpoint = (HTC_ENDPOINT *)pScatterReq->Context; - HTC_TARGET *target = (HTC_TARGET *)pEndpoint->target; - A_STATUS status = A_OK; - HTC_PACKET_QUEUE sendCompletes; + struct htc_packet *pPacket; + struct htc_endpoint *pEndpoint = (struct htc_endpoint *)pScatterReq->Context; + struct htc_target *target = (struct htc_target *)pEndpoint->target; + int status = 0; + struct htc_packet_queue sendCompletes; INIT_HTC_PACKET_QUEUE(&sendCompletes); @@ -280,14 +280,14 @@ static void HTCAsyncSendScatterCompletion(HIF_SCATTER_REQ *pScatterReq) DEV_FINISH_SCATTER_OPERATION(pScatterReq); - if (A_FAILED(pScatterReq->CompletionStatus)) { + if (pScatterReq->CompletionStatus) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("** Send Scatter Request Failed: %d \n",pScatterReq->CompletionStatus)); status = A_ERROR; } /* walk through the scatter list and process */ for (i = 0; i < pScatterReq->ValidScatterEntries; i++) { - pPacket = (HTC_PACKET *)(pScatterReq->ScatterList[i].pCallerContexts[0]); + pPacket = (struct htc_packet *)(pScatterReq->ScatterList[i].pCallerContexts[0]); A_ASSERT(pPacket != NULL); pPacket->Status = status; CompleteSentPacket(target,pEndpoint,pPacket); @@ -309,21 +309,21 @@ static void HTCAsyncSendScatterCompletion(HIF_SCATTER_REQ *pScatterReq) * - a message that will consume a partial credit will stop the bundling process early * - we drop below the minimum number of messages for a bundle * */ -static void HTCIssueSendBundle(HTC_ENDPOINT *pEndpoint, - HTC_PACKET_QUEUE *pQueue, +static void HTCIssueSendBundle(struct htc_endpoint *pEndpoint, + struct htc_packet_queue *pQueue, int *pBundlesSent, int *pTotalBundlesPkts) { int pktsToScatter; unsigned int scatterSpaceRemaining; - HIF_SCATTER_REQ *pScatterReq = NULL; + struct hif_scatter_req *pScatterReq = NULL; int i, packetsInScatterReq; unsigned int transferLength; - HTC_PACKET *pPacket; - A_BOOL done = FALSE; + struct htc_packet *pPacket; + bool done = false; int bundlesSent = 0; int totalPktsInBundle = 0; - HTC_TARGET *target = pEndpoint->target; + struct htc_target *target = pEndpoint->target; int creditRemainder = 0; int creditPad; @@ -361,7 +361,7 @@ static void HTCIssueSendBundle(HTC_ENDPOINT *pEndpoint, pPacket = HTC_GET_PKT_AT_HEAD(pQueue); if (pPacket == NULL) { - A_ASSERT(FALSE); + A_ASSERT(false); break; } @@ -400,7 +400,7 @@ static void HTCIssueSendBundle(HTC_ENDPOINT *pEndpoint, if (NULL == pPacket) { /* can't bundle */ - done = TRUE; + done = true; break; } @@ -450,7 +450,7 @@ static void HTCIssueSendBundle(HTC_ENDPOINT *pEndpoint, if (packetsInScatterReq > 0) { /* work backwards to requeue requests */ for (i = (packetsInScatterReq - 1); i >= 0; i--) { - pPacket = (HTC_PACKET *)(pScatterReq->ScatterList[i].pCallerContexts[0]); + pPacket = (struct htc_packet *)(pScatterReq->ScatterList[i].pCallerContexts[0]); if (pPacket != NULL) { /* undo any prep */ HTC_UNPREPARE_SEND_PKT(pPacket); @@ -477,12 +477,12 @@ static void HTCIssueSendBundle(HTC_ENDPOINT *pEndpoint, /* * if there are no credits, the packet(s) remains in the queue. * this function returns the result of the attempt to send a queue of HTC packets */ -static HTC_SEND_QUEUE_RESULT HTCTrySend(HTC_TARGET *target, - HTC_ENDPOINT *pEndpoint, - HTC_PACKET_QUEUE *pCallersSendQueue) +static HTC_SEND_QUEUE_RESULT HTCTrySend(struct htc_target *target, + struct htc_endpoint *pEndpoint, + struct htc_packet_queue *pCallersSendQueue) { - HTC_PACKET_QUEUE sendQueue; /* temp queue to hold packets at various stages */ - HTC_PACKET *pPacket; + struct htc_packet_queue sendQueue; /* temp queue to hold packets at various stages */ + struct htc_packet *pPacket; int bundlesSent; int pktsInBundles; int overflow; @@ -546,7 +546,7 @@ static HTC_SEND_QUEUE_RESULT HTCTrySend(HTC_TARGET *target, /* the caller's queue has all the packets that won't fit*/ /* walk through the caller's queue and indicate each one to the send full handler */ - ITERATE_OVER_LIST_ALLOW_REMOVE(&pCallersSendQueue->QueueHead, pPacket, HTC_PACKET, ListLink) { + ITERATE_OVER_LIST_ALLOW_REMOVE(&pCallersSendQueue->QueueHead, pPacket, struct htc_packet, ListLink) { AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Indicating overflowed TX packet: 0x%lX \n", (unsigned long)pPacket)); @@ -571,7 +571,7 @@ static HTC_SEND_QUEUE_RESULT HTCTrySend(HTC_TARGET *target, } } - } while (FALSE); + } while (false); if (result != HTC_SEND_QUEUE_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCTrySend: \n")); @@ -602,7 +602,7 @@ static HTC_SEND_QUEUE_RESULT HTCTrySend(HTC_TARGET *target, /* now drain the endpoint TX queue for transmission as long as we have enough * credits */ - while (TRUE) { + while (true) { if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) == 0) { break; @@ -623,7 +623,7 @@ static HTC_SEND_QUEUE_RESULT HTCTrySend(HTC_TARGET *target, bundlesSent = 0; pktsInBundles = 0; - while (TRUE) { + while (true) { /* try to send a bundle on each pass */ if ((target->SendBundlingEnabled) && @@ -668,11 +668,11 @@ static HTC_SEND_QUEUE_RESULT HTCTrySend(HTC_TARGET *target, return HTC_SEND_QUEUE_OK; } -A_STATUS HTCSendPktsMultiple(HTC_HANDLE HTCHandle, HTC_PACKET_QUEUE *pPktQueue) +int HTCSendPktsMultiple(HTC_HANDLE HTCHandle, struct htc_packet_queue *pPktQueue) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - HTC_ENDPOINT *pEndpoint; - HTC_PACKET *pPacket; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_endpoint *pEndpoint; + struct htc_packet *pPacket; AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCSendPktsMultiple: Queue: 0x%lX, Pkts %d \n", (unsigned long)pPktQueue, HTC_PACKET_QUEUE_DEPTH(pPktQueue))); @@ -705,13 +705,13 @@ A_STATUS HTCSendPktsMultiple(HTC_HANDLE HTCHandle, HTC_PACKET_QUEUE *pPktQueue) AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCSendPktsMultiple \n")); - return A_OK; + return 0; } /* HTC API - HTCSendPkt */ -A_STATUS HTCSendPkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket) +int HTCSendPkt(HTC_HANDLE HTCHandle, struct htc_packet *pPacket) { - HTC_PACKET_QUEUE queue; + struct htc_packet_queue queue; AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+-HTCSendPkt: Enter endPointId: %d, buffer: 0x%lX, length: %d \n", @@ -721,10 +721,10 @@ A_STATUS HTCSendPkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket) } /* check TX queues to drain because of credit distribution update */ -static INLINE void HTCCheckEndpointTxQueues(HTC_TARGET *target) +static INLINE void HTCCheckEndpointTxQueues(struct htc_target *target) { - HTC_ENDPOINT *pEndpoint; - HTC_ENDPOINT_CREDIT_DIST *pDistItem; + struct htc_endpoint *pEndpoint; + struct htc_endpoint_credit_dist *pDistItem; AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCCheckEndpointTxQueues \n")); pDistItem = target->EpCreditDistributionListHead; @@ -734,7 +734,7 @@ static INLINE void HTCCheckEndpointTxQueues(HTC_TARGET *target) * NOTE: no locks need to be taken since the distribution list * is not dynamic (cannot be re-ordered) and we are not modifying any state */ while (pDistItem != NULL) { - pEndpoint = (HTC_ENDPOINT *)pDistItem->pHTCReserved; + pEndpoint = (struct htc_endpoint *)pDistItem->pHTCReserved; if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) > 0) { AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Ep %d has %d credits and %d Packets in TX Queue \n", @@ -753,12 +753,12 @@ static INLINE void HTCCheckEndpointTxQueues(HTC_TARGET *target) } /* process credit reports and call distribution function */ -void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint) +void HTCProcessCreditRpt(struct htc_target *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint) { int i; - HTC_ENDPOINT *pEndpoint; + struct htc_endpoint *pEndpoint; int totalCredits = 0; - A_BOOL doDist = FALSE; + bool doDist = false; AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCProcessCreditRpt, Credit Report Entries:%d \n", NumEntries)); @@ -767,7 +767,7 @@ void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEnt for (i = 0; i < NumEntries; i++, pRpt++) { if (pRpt->EndpointID >= ENDPOINT_MAX) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); break; } @@ -807,7 +807,7 @@ void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEnt * will handle giving out credits back to the endpoints */ pEndpoint->CreditDist.TxCreditsToDist += pRpt->Credits; /* flag that we have to do the distribution */ - doDist = TRUE; + doDist = true; } /* refresh tx depth for distribution function that will recover these credits @@ -838,11 +838,11 @@ void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEnt } /* flush endpoint TX queue */ -static void HTCFlushEndpointTX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_TX_TAG Tag) +static void HTCFlushEndpointTX(struct htc_target *target, struct htc_endpoint *pEndpoint, HTC_TX_TAG Tag) { - HTC_PACKET *pPacket; - HTC_PACKET_QUEUE discardQueue; - HTC_PACKET_QUEUE container; + struct htc_packet *pPacket; + struct htc_packet_queue discardQueue; + struct htc_packet_queue container; /* initialize the discard queue */ INIT_HTC_PACKET_QUEUE(&discardQueue); @@ -850,7 +850,7 @@ static void HTCFlushEndpointTX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_ LOCK_HTC_TX(target); /* interate from the front of the TX queue and flush out packets */ - ITERATE_OVER_LIST_ALLOW_REMOVE(&pEndpoint->TxQueue.QueueHead, pPacket, HTC_PACKET, ListLink) { + ITERATE_OVER_LIST_ALLOW_REMOVE(&pEndpoint->TxQueue.QueueHead, pPacket, struct htc_packet, ListLink) { /* check for removal */ if ((HTC_TX_PACKET_TAG_ALL == Tag) || (Tag == pPacket->PktInfo.AsTx.Tag)) { @@ -879,7 +879,7 @@ static void HTCFlushEndpointTX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_ } -void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist) +void DumpCreditDist(struct htc_endpoint_credit_dist *pEPDist) { AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("--- EP : %d ServiceID: 0x%X --------------\n", pEPDist->Endpoint, pEPDist->ServiceID)); @@ -895,13 +895,13 @@ void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist) AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsPerMaxMsg : %d \n", pEPDist->TxCreditsPerMaxMsg)); AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsToDist : %d \n", pEPDist->TxCreditsToDist)); AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxQueueDepth : %d \n", - HTC_PACKET_QUEUE_DEPTH(&((HTC_ENDPOINT *)pEPDist->pHTCReserved)->TxQueue))); + HTC_PACKET_QUEUE_DEPTH(&((struct htc_endpoint *)pEPDist->pHTCReserved)->TxQueue))); AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("----------------------------------------------------\n")); } -void DumpCreditDistStates(HTC_TARGET *target) +void DumpCreditDistStates(struct htc_target *target) { - HTC_ENDPOINT_CREDIT_DIST *pEPList = target->EpCreditDistributionListHead; + struct htc_endpoint_credit_dist *pEPList = target->EpCreditDistributionListHead; while (pEPList != NULL) { DumpCreditDist(pEPList); @@ -917,9 +917,9 @@ void DumpCreditDistStates(HTC_TARGET *target) } /* flush all send packets from all endpoint queues */ -void HTCFlushSendPkts(HTC_TARGET *target) +void HTCFlushSendPkts(struct htc_target *target) { - HTC_ENDPOINT *pEndpoint; + struct htc_endpoint *pEndpoint; int i; if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) { @@ -941,11 +941,11 @@ void HTCFlushSendPkts(HTC_TARGET *target) /* HTC API to flush an endpoint's TX queue*/ void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG Tag) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint]; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_endpoint *pEndpoint = &target->EndPoint[Endpoint]; if (pEndpoint->ServiceID == 0) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); /* not in use.. */ return; } @@ -956,14 +956,14 @@ void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG /* HTC API to indicate activity to the credit distribution function */ void HTCIndicateActivityChange(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, - A_BOOL Active) + bool Active) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint]; - A_BOOL doDist = FALSE; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_endpoint *pEndpoint = &target->EndPoint[Endpoint]; + bool doDist = false; if (pEndpoint->ServiceID == 0) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); /* not in use.. */ return; } @@ -974,13 +974,13 @@ void HTCIndicateActivityChange(HTC_HANDLE HTCHandle, if (!(pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE)) { /* mark active now */ pEndpoint->CreditDist.DistFlags |= HTC_EP_ACTIVE; - doDist = TRUE; + doDist = true; } } else { if (pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE) { /* mark inactive now */ pEndpoint->CreditDist.DistFlags &= ~HTC_EP_ACTIVE; - doDist = TRUE; + doDist = true; } } @@ -1005,19 +1005,19 @@ void HTCIndicateActivityChange(HTC_HANDLE HTCHandle, } } -A_BOOL HTCIsEndpointActive(HTC_HANDLE HTCHandle, +bool HTCIsEndpointActive(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint]; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_endpoint *pEndpoint = &target->EndPoint[Endpoint]; if (pEndpoint->ServiceID == 0) { - return FALSE; + return false; } if (pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE) { - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/drivers/staging/ath6kl/htc2/htc_services.c b/drivers/staging/ath6kl/htc2/htc_services.c index 64fddc0..c48070c 100644 --- a/drivers/staging/ath6kl/htc2/htc_services.c +++ b/drivers/staging/ath6kl/htc2/htc_services.c @@ -22,21 +22,21 @@ //============================================================================== #include "htc_internal.h" -void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket) +void HTCControlTxComplete(void *Context, struct htc_packet *pPacket) { /* not implemented * we do not send control TX frames during normal runtime, only during setup */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); } /* callback when a control message arrives on this endpoint */ -void HTCControlRecv(void *Context, HTC_PACKET *pPacket) +void HTCControlRecv(void *Context, struct htc_packet *pPacket) { AR_DEBUG_ASSERT(pPacket->Endpoint == ENDPOINT_0); if (pPacket->Status == A_ECANCELED) { /* this is a flush operation, return the control packet back to the pool */ - HTC_FREE_CONTROL_RX((HTC_TARGET*)Context,pPacket); + HTC_FREE_CONTROL_RX((struct htc_target*)Context,pPacket); return; } @@ -44,7 +44,7 @@ void HTCControlRecv(void *Context, HTC_PACKET *pPacket) if (pPacket->ActualLength > 0) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCControlRecv, got message with length:%d \n", - pPacket->ActualLength + (A_UINT32)HTC_HDR_LENGTH)); + pPacket->ActualLength + (u32)HTC_HDR_LENGTH)); #ifdef ATH_DEBUG_MODULE /* dump header and message */ @@ -54,13 +54,13 @@ void HTCControlRecv(void *Context, HTC_PACKET *pPacket) #endif } - HTC_RECYCLE_RX_PKT((HTC_TARGET*)Context,pPacket,&((HTC_TARGET*)Context)->EndPoint[0]); + HTC_RECYCLE_RX_PKT((struct htc_target*)Context,pPacket,&((struct htc_target*)Context)->EndPoint[0]); } -A_STATUS HTCSendSetupComplete(HTC_TARGET *target) +int HTCSendSetupComplete(struct htc_target *target) { - HTC_PACKET *pSendPacket = NULL; - A_STATUS status; + struct htc_packet *pSendPacket = NULL; + int status; do { /* allocate a packet to send to the target */ @@ -73,7 +73,7 @@ A_STATUS HTCSendSetupComplete(HTC_TARGET *target) if (target->HTCTargetVersion >= HTC_VERSION_2P1) { HTC_SETUP_COMPLETE_EX_MSG *pSetupCompleteEx; - A_UINT32 setupFlags = 0; + u32 setupFlags = 0; pSetupCompleteEx = (HTC_SETUP_COMPLETE_EX_MSG *)pSendPacket->pBuffer; A_MEMZERO(pSetupCompleteEx, sizeof(HTC_SETUP_COMPLETE_EX_MSG)); @@ -83,10 +83,10 @@ A_STATUS HTCSendSetupComplete(HTC_TARGET *target) setupFlags |= HTC_SETUP_COMPLETE_FLAGS_ENABLE_BUNDLE_RECV; pSetupCompleteEx->MaxMsgsPerBundledRecv = target->MaxMsgPerBundle; } - A_MEMCPY(&pSetupCompleteEx->SetupFlags, &setupFlags, sizeof(pSetupCompleteEx->SetupFlags)); + memcpy(&pSetupCompleteEx->SetupFlags, &setupFlags, sizeof(pSetupCompleteEx->SetupFlags)); SET_HTC_PACKET_INFO_TX(pSendPacket, NULL, - (A_UINT8 *)pSetupCompleteEx, + (u8 *)pSetupCompleteEx, sizeof(HTC_SETUP_COMPLETE_EX_MSG), ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); @@ -99,7 +99,7 @@ A_STATUS HTCSendSetupComplete(HTC_TARGET *target) pSetupComplete->MessageID = HTC_MSG_SETUP_COMPLETE_ID; SET_HTC_PACKET_INFO_TX(pSendPacket, NULL, - (A_UINT8 *)pSetupComplete, + (u8 *)pSetupComplete, sizeof(HTC_SETUP_COMPLETE_MSG), ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); @@ -111,7 +111,7 @@ A_STATUS HTCSendSetupComplete(HTC_TARGET *target) /* send the message */ status = HTCIssueSend(target,pSendPacket); - } while (FALSE); + } while (false); if (pSendPacket != NULL) { HTC_FREE_CONTROL_TX(target,pSendPacket); @@ -121,18 +121,18 @@ A_STATUS HTCSendSetupComplete(HTC_TARGET *target) } -A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, - HTC_SERVICE_CONNECT_REQ *pConnectReq, - HTC_SERVICE_CONNECT_RESP *pConnectResp) +int HTCConnectService(HTC_HANDLE HTCHandle, + struct htc_service_connect_req *pConnectReq, + struct htc_service_connect_resp *pConnectResp) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); - A_STATUS status = A_OK; - HTC_PACKET *pRecvPacket = NULL; - HTC_PACKET *pSendPacket = NULL; + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + int status = 0; + struct htc_packet *pRecvPacket = NULL; + struct htc_packet *pSendPacket = NULL; HTC_CONNECT_SERVICE_RESPONSE_MSG *pResponseMsg; HTC_CONNECT_SERVICE_MSG *pConnectMsg; HTC_ENDPOINT_ID assignedEndpoint = ENDPOINT_MAX; - HTC_ENDPOINT *pEndpoint; + struct htc_endpoint *pEndpoint; unsigned int maxMsgSize = 0; AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCConnectService, target:0x%lX SvcID:0x%X \n", @@ -151,7 +151,7 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, pSendPacket = HTC_ALLOC_CONTROL_TX(target); if (NULL == pSendPacket) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_NO_MEMORY; break; } @@ -166,7 +166,7 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, if ((pConnectReq->pMetaData != NULL) && (pConnectReq->MetaDataLength <= HTC_SERVICE_META_DATA_MAX_LENGTH)) { /* copy meta data into message buffer (after header ) */ - A_MEMCPY((A_UINT8 *)pConnectMsg + sizeof(HTC_CONNECT_SERVICE_MSG), + memcpy((u8 *)pConnectMsg + sizeof(HTC_CONNECT_SERVICE_MSG), pConnectReq->pMetaData, pConnectReq->MetaDataLength); pConnectMsg->ServiceMetaLength = pConnectReq->MetaDataLength; @@ -174,7 +174,7 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, SET_HTC_PACKET_INFO_TX(pSendPacket, NULL, - (A_UINT8 *)pConnectMsg, + (u8 *)pConnectMsg, sizeof(HTC_CONNECT_SERVICE_MSG) + pConnectMsg->ServiceMetaLength, ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); @@ -184,14 +184,14 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, HTC_PREPARE_SEND_PKT(pSendPacket,0,0,0); status = HTCIssueSend(target,pSendPacket); - if (A_FAILED(status)) { + if (status) { break; } /* wait for response */ status = HTCWaitforControlMessage(target, &pRecvPacket); - if (A_FAILED(status)) { + if (status) { break; } /* we controlled the buffer creation so it has to be properly aligned */ @@ -200,7 +200,7 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, if ((pResponseMsg->MessageID != HTC_MSG_CONNECT_SERVICE_RESPONSE_ID) || (pRecvPacket->ActualLength < sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG))) { /* this message is not valid */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); status = A_EPROTO; break; } @@ -224,8 +224,8 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, /* caller supplied a buffer and the target responded with data */ int copyLength = min((int)pConnectResp->BufferLength, (int)pResponseMsg->ServiceMetaLength); /* copy the meta data */ - A_MEMCPY(pConnectResp->pMetaData, - ((A_UINT8 *)pResponseMsg) + sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG), + memcpy(pConnectResp->pMetaData, + ((u8 *)pResponseMsg) + sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG), copyLength); pConnectResp->ActualLength = copyLength; } @@ -236,12 +236,12 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, status = A_EPROTO; if (assignedEndpoint >= ENDPOINT_MAX) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); break; } if (0 == maxMsgSize) { - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); break; } @@ -249,7 +249,7 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, pEndpoint->Id = assignedEndpoint; if (pEndpoint->ServiceID != 0) { /* endpoint already in use! */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); break; } @@ -275,7 +275,7 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, * since the host will actually issue smaller messages in the Send path */ if (pConnectReq->MaxSendMsgSize > maxMsgSize) { /* can't be larger than the maximum the target can support */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); break; } pEndpoint->CreditDist.TxCreditsPerMaxMsg = pConnectReq->MaxSendMsgSize / target->TargetCreditSize; @@ -290,9 +290,9 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, /* save local connection flags */ pEndpoint->LocalConnectionFlags = pConnectReq->LocalConnectionFlags; - status = A_OK; + status = 0; - } while (FALSE); + } while (false); if (pSendPacket != NULL) { HTC_FREE_CONTROL_TX(target,pSendPacket); @@ -307,9 +307,9 @@ A_STATUS HTCConnectService(HTC_HANDLE HTCHandle, return status; } -static void AddToEndpointDistList(HTC_TARGET *target, HTC_ENDPOINT_CREDIT_DIST *pEpDist) +static void AddToEndpointDistList(struct htc_target *target, struct htc_endpoint_credit_dist *pEpDist) { - HTC_ENDPOINT_CREDIT_DIST *pCurEntry,*pLastEntry; + struct htc_endpoint_credit_dist *pCurEntry,*pLastEntry; if (NULL == target->EpCreditDistributionListHead) { target->EpCreditDistributionListHead = pEpDist; @@ -336,10 +336,10 @@ static void AddToEndpointDistList(HTC_TARGET *target, HTC_ENDPOINT_CREDIT_DIST * /* default credit init callback */ static void HTCDefaultCreditInit(void *Context, - HTC_ENDPOINT_CREDIT_DIST *pEPList, + struct htc_endpoint_credit_dist *pEPList, int TotalCredits) { - HTC_ENDPOINT_CREDIT_DIST *pCurEpDist; + struct htc_endpoint_credit_dist *pCurEpDist; int totalEps = 0; int creditsPerEndpoint; @@ -360,7 +360,7 @@ static void HTCDefaultCreditInit(void *Context, if (creditsPerEndpoint < pCurEpDist->TxCreditsPerMaxMsg) { /* too many endpoints and not enough credits */ - AR_DEBUG_ASSERT(FALSE); + AR_DEBUG_ASSERT(false); break; } /* our minimum is set for at least 1 max message */ @@ -379,10 +379,10 @@ static void HTCDefaultCreditInit(void *Context, /* default credit distribution callback, NOTE, this callback holds the TX lock */ void HTCDefaultCreditDist(void *Context, - HTC_ENDPOINT_CREDIT_DIST *pEPDistList, + struct htc_endpoint_credit_dist *pEPDistList, HTC_CREDIT_DIST_REASON Reason) { - HTC_ENDPOINT_CREDIT_DIST *pCurEpDist; + struct htc_endpoint_credit_dist *pCurEpDist; if (Reason == HTC_CREDIT_DIST_SEND_COMPLETE) { pCurEpDist = pEPDistList; @@ -408,7 +408,7 @@ void HTCSetCreditDistribution(HTC_HANDLE HTCHandle, HTC_SERVICE_ID ServicePriorityOrder[], int ListLength) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); int i; int ep; |