diff --git a/htc/dl_list.h b/htc/dl_list.h index 85b1b8542a..468ea0362e 100644 --- a/htc/dl_list.h +++ b/htc/dl_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2014, 2017, 2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -127,9 +127,9 @@ static inline PDL_LIST dl_list_insert_head(PDL_LIST pList, PDL_LIST pAdd) */ static inline PDL_LIST dl_list_remove(PDL_LIST pDel) { - if (pDel->pNext != NULL) + if (pDel->pNext) pDel->pNext->pPrev = pDel->pPrev; - if (pDel->pPrev != NULL) + if (pDel->pPrev) pDel->pPrev->pNext = pDel->pNext; /* point back to itself just to be safe, if remove is called again */ pDel->pNext = pDel; diff --git a/htc/htc.c b/htc/htc.c index a1f30e883b..5ccd803b20 100644 --- a/htc/htc.c +++ b/htc/htc.c @@ -61,7 +61,7 @@ static void destroy_htc_tx_ctrl_packet(HTC_PACKET *pPacket) qdf_nbuf_t netbuf; netbuf = (qdf_nbuf_t) GET_HTC_PACKET_NET_BUF_CONTEXT(pPacket); - if (netbuf != NULL) + if (netbuf) qdf_nbuf_free(netbuf); qdf_mem_free(pPacket); } @@ -73,11 +73,11 @@ static HTC_PACKET *build_htc_tx_ctrl_packet(qdf_device_t osdev) do { pPacket = (HTC_PACKET *) qdf_mem_malloc(sizeof(HTC_PACKET)); - if (pPacket == NULL) + if (!pPacket) break; netbuf = qdf_nbuf_alloc(osdev, HTC_CONTROL_BUFFER_SIZE, 20, 4, true); - if (NULL == netbuf) { + if (!netbuf) { qdf_mem_free(pPacket); pPacket = NULL; break; @@ -142,7 +142,7 @@ static void htc_cleanup(HTC_TARGET *target) HTC_PACKET_QUEUE *pkt_queue; qdf_nbuf_t netbuf; - if (target->hif_dev != NULL) { + if (target->hif_dev) { hif_detach_htc(target->hif_dev); hif_mask_interrupt_call(target->hif_dev); target->hif_dev = NULL; @@ -150,7 +150,7 @@ static void htc_cleanup(HTC_TARGET *target) while (true) { pPacket = allocate_htc_packet_container(target); - if (pPacket == NULL) + if (!pPacket) break; qdf_mem_free(pPacket); } @@ -174,10 +174,10 @@ static void htc_cleanup(HTC_TARGET *target) #ifdef TODO_FIXME while (true) { pPacket = htc_alloc_control_tx_packet(target); - if (pPacket == NULL) + if (!pPacket) break; netbuf = (qdf_nbuf_t) GET_HTC_PACKET_NET_BUF_CONTEXT(pPacket); - if (netbuf != NULL) + if (netbuf) qdf_nbuf_free(netbuf); qdf_mem_free(pPacket); } @@ -236,7 +236,7 @@ int htc_runtime_resume(HTC_HANDLE htc_ctx) { HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(htc_ctx); - if (target == NULL) + if (!target) return 0; qdf_sched_work(0, &target->queue_kicker); @@ -255,7 +255,7 @@ HTC_HANDLE htc_create(void *ol_sc, struct htc_init_info *pInfo, HTC_TARGET *target = NULL; int i; - if (ol_sc == NULL) { + if (!ol_sc) { HTC_ERROR("%s: ol_sc = NULL", __func__); return NULL; } @@ -294,14 +294,14 @@ HTC_HANDLE htc_create(void *ol_sc, struct htc_init_info *pInfo, for (i = 0; i < HTC_PACKET_CONTAINER_ALLOCATION; i++) { HTC_PACKET *pPacket = (HTC_PACKET *) qdf_mem_malloc(sizeof(HTC_PACKET)); - if (pPacket != NULL) + if (pPacket) free_htc_packet_container(target, pPacket); } #ifdef TODO_FIXME for (i = 0; i < NUM_CONTROL_TX_BUFFERS; i++) { pPacket = build_htc_tx_ctrl_packet(); - if (pPacket == NULL) + if (!pPacket) break; htc_free_control_tx_packet(target, pPacket); } @@ -606,7 +606,7 @@ QDF_STATUS htc_wait_target(HTC_HANDLE HTCHandle) for (i = 0; i < MAX_HTC_RX_BUNDLE; i++) { rx_bundle_packet = allocate_htc_bundle_packet(target); - if (rx_bundle_packet != NULL) + if (rx_bundle_packet) rx_bundle_packet->ListLink.pNext = (DL_LIST *)temp_bundle_packet; else @@ -694,7 +694,7 @@ QDF_STATUS htc_start(HTC_HANDLE HTCHandle) /* allocate a buffer to send */ pSendPacket = htc_alloc_control_tx_packet(target); - if (NULL == pSendPacket) { + if (!pSendPacket) { AR_DEBUG_ASSERT(false); qdf_print("%s: allocControlTxPacket failed", __func__); @@ -905,7 +905,7 @@ bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle, LOCK_HTC_RX(target); if (sample) { - A_ASSERT(pStats != NULL); + A_ASSERT(pStats); /* return the stats to the caller */ qdf_mem_copy(pStats, &target->endpoint[Endpoint].endpoint_stats, sizeof(struct htc_endpoint_stats)); diff --git a/htc/htc_packet.h b/htc/htc_packet.h index a205ae454c..8ac7db432c 100644 --- a/htc/htc_packet.h +++ b/htc/htc_packet.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, 2016-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2014, 2016-2017, 2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -242,7 +242,7 @@ static inline HTC_PACKET *htc_packet_dequeue(HTC_PACKET_QUEUE *queue) { DL_LIST *pItem = dl_list_remove_item_from_head(&queue->QueueHead); - if (pItem != NULL) { + if (pItem) { queue->Depth--; return A_CONTAINING_STRUCT(pItem, HTC_PACKET, ListLink); } @@ -254,7 +254,7 @@ static inline HTC_PACKET *htc_packet_dequeue_tail(HTC_PACKET_QUEUE *queue) { DL_LIST *pItem = dl_list_remove_item_from_tail(&queue->QueueHead); - if (pItem != NULL) { + if (pItem) { queue->Depth--; return A_CONTAINING_STRUCT(pItem, HTC_PACKET, ListLink); } diff --git a/htc/htc_recv.c b/htc/htc_recv.c index e26055f096..6336bd5c86 100644 --- a/htc/htc_recv.c +++ b/htc/htc_recv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -76,7 +76,7 @@ static A_STATUS htc_process_trailer(HTC_TARGET *target, static void do_recv_completion_pkt(HTC_ENDPOINT *pEndpoint, HTC_PACKET *pPacket) { - if (pEndpoint->EpCallBacks.EpRecv == NULL) { + if (!pEndpoint->EpCallBacks.EpRecv) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC ep %d has NULL recv callback on packet %pK\n", pEndpoint->Id, @@ -146,7 +146,7 @@ HTC_PACKET *allocate_htc_packet_container(HTC_TARGET *target) LOCK_HTC_RX(target); - if (NULL == target->pHTCPacketStructPool) { + if (!target->pHTCPacketStructPool) { UNLOCK_HTC_RX(target); return NULL; } @@ -165,7 +165,7 @@ void free_htc_packet_container(HTC_TARGET *target, HTC_PACKET *pPacket) pPacket->ListLink.pPrev = NULL; LOCK_HTC_RX(target); - if (NULL == target->pHTCPacketStructPool) { + if (!target->pHTCPacketStructPool) { target->pHTCPacketStructPool = pPacket; pPacket->ListLink.pNext = NULL; } else { @@ -197,7 +197,7 @@ qdf_nbuf_t rx_sg_to_single_netbuf(HTC_TARGET *target) } new_skb = qdf_nbuf_alloc(target->ExpRxSgTotalLen, 0, 4, false); - if (new_skb == NULL) { + if (!new_skb) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("rx_sg_to_single_netbuf: can't allocate %u size netbuf\n", target->ExpRxSgTotalLen)); @@ -214,7 +214,7 @@ qdf_nbuf_t rx_sg_to_single_netbuf(HTC_TARGET *target) anbdata_new += qdf_nbuf_len(skb); qdf_nbuf_free(skb); skb = qdf_nbuf_queue_remove(rx_sg_queue); - } while (skb != NULL); + } while (skb); RESET_RX_SG_CONFIG(target); return new_skb; @@ -257,7 +257,7 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf, qdf_nbuf_queue_add(&target->RxSgQueue, netbuf); if (target->CurRxSgTotalLen == target->ExpRxSgTotalLen) { netbuf = rx_sg_to_single_netbuf(target); - if (netbuf == NULL) { + if (!netbuf) { UNLOCK_HTC_RX(target); goto _out; } @@ -481,7 +481,7 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf, * TODO_FIXME */ pPacket = allocate_htc_packet_container(target); - if (NULL == pPacket) { + if (!pPacket) { status = QDF_STATUS_E_RESOURCES; break; } @@ -507,7 +507,7 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf, _out: #endif - if (netbuf != NULL) + if (netbuf) qdf_nbuf_free(netbuf); return status; @@ -525,7 +525,7 @@ A_STATUS htc_add_receive_pkt_multiple(HTC_HANDLE HTCHandle, pFirstPacket = htc_get_pkt_at_head(pPktQueue); - if (NULL == pFirstPacket) { + if (!pFirstPacket) { A_ASSERT(false); return A_EINVAL; } @@ -581,7 +581,7 @@ void htc_flush_rx_hold_queue(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint) while (1) { pPacket = htc_packet_dequeue(&pEndpoint->RxBufferHoldQueue); - if (pPacket == NULL) + if (!pPacket) break; UNLOCK_HTC_RX(target); pPacket->Status = QDF_STATUS_E_CANCELED; diff --git a/htc/htc_send.c b/htc/htc_send.c index 01cf49b2a8..cac5988aea 100644 --- a/htc/htc_send.c +++ b/htc/htc_send.c @@ -129,7 +129,7 @@ static void send_packet_completion(HTC_TARGET *target, HTC_PACKET *pPacket) pEndpoint->Id, pPacket)); EpTxComplete = pEndpoint->EpCallBacks.EpTxComplete; - if (EpTxComplete != NULL) + if (EpTxComplete) EpTxComplete(pEndpoint->EpCallBacks.pContext, pPacket); else qdf_nbuf_free(pPacket->pPktContext); @@ -151,7 +151,7 @@ HTC_PACKET *allocate_htc_bundle_packet(HTC_TARGET *target) qdf_nbuf_t netbuf; LOCK_HTC_TX(target); - if (NULL == target->pBundleFreeList) { + if (!target->pBundleFreeList) { UNLOCK_HTC_TX(target); netbuf = qdf_nbuf_alloc(NULL, target->MaxMsgsPerHTCBundle * @@ -239,7 +239,7 @@ void free_htc_bundle_packet(HTC_TARGET *target, HTC_PACKET *pPacket) INIT_HTC_PACKET_QUEUE(pQueueSave); LOCK_HTC_TX(target); - if (target->pBundleFreeList == NULL) { + if (!target->pBundleFreeList) { target->pBundleFreeList = pPacket; pPacket->ListLink.pNext = NULL; } else { @@ -378,7 +378,7 @@ static void htc_issue_packets_bundle(HTC_TARGET *target, pQueueSave = (HTC_PACKET_QUEUE *) pPacketTx->pContext; while (1) { pPacket = htc_packet_dequeue(pPktQueue); - if (pPacket == NULL) + if (!pPacket) break; creditPad = 0; transferLength = pPacket->ActualLength + HTC_HDR_LENGTH; @@ -527,7 +527,7 @@ static QDF_STATUS htc_issue_packets(HTC_TARGET *target, * placed in a bundle, and send it by normal way */ pPacket = htc_packet_dequeue(pPktQueue); - if (NULL == pPacket) { + if (!pPacket) { /* local queue is fully drained */ break; } @@ -777,7 +777,7 @@ static void get_htc_send_packets_credit_based(HTC_TARGET *target, sendFlags = 0; /* get packet at head, but don't remove it */ pPacket = htc_get_pkt_at_head(tx_queue); - if (pPacket == NULL) { + if (!pPacket) { if (do_pm_get) hif_pm_runtime_put(target->hif_dev); break; @@ -907,7 +907,7 @@ static void get_htc_send_packets(HTC_TARGET *target, } pPacket = htc_packet_dequeue(tx_queue); - if (pPacket == NULL) { + if (!pPacket) { if (do_pm_get) hif_pm_runtime_put(target->hif_dev); break; @@ -984,7 +984,7 @@ static enum HTC_SEND_QUEUE_RESULT htc_try_send(HTC_TARGET *target, /* caller didn't provide a queue, just wants us to check * queues and send */ - if (pCallersSendQueue == NULL) + if (!pCallersSendQueue) break; if (HTC_QUEUE_EMPTY(pCallersSendQueue)) { @@ -1017,7 +1017,7 @@ static enum HTC_SEND_QUEUE_RESULT htc_try_send(HTC_TARGET *target, pEndpoint->MaxTxQueueDepth)); } if ((overflow <= 0) - || (pEndpoint->EpCallBacks.EpSendFull == NULL)) { + || (!pEndpoint->EpCallBacks.EpSendFull)) { /* all packets will fit or caller did not provide send * full indication handler * just move all of them to local sendQueue object @@ -1037,7 +1037,7 @@ static enum HTC_SEND_QUEUE_RESULT htc_try_send(HTC_TARGET *target, for (i = 0; i < goodPkts; i++) { /* pop off caller's queue */ pPacket = htc_packet_dequeue(pCallersSendQueue); - A_ASSERT(pPacket != NULL); + A_ASSERT(pPacket); /* insert into local queue */ HTC_PACKET_ENQUEUE(&sendQueue, pPacket); } @@ -1370,7 +1370,7 @@ static inline QDF_STATUS __htc_send_pkt(HTC_HANDLE HTCHandle, /* get packet at head to figure out which endpoint these packets will * go into */ - if (NULL == pPacket) { + if (!pPacket) { OL_ATH_HTC_PKT_ERROR_COUNT_INCR(target, GET_HTC_PKT_Q_FAIL); AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-__htc_send_pkt\n")); return QDF_STATUS_E_INVAL; @@ -1745,7 +1745,7 @@ QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket, htc_issue_packets_bundle(target, pEndpoint, &sendQueue); } pPacket = htc_packet_dequeue(&sendQueue); - if (pPacket == NULL) + if (!pPacket) break; netbuf = GET_HTC_PACKET_NET_BUF_CONTEXT(pPacket); @@ -1866,7 +1866,7 @@ static HTC_PACKET *htc_lookup_tx_packet(HTC_TARGET *target, ITERATE_OVER_LIST_ALLOW_REMOVE(&lookupQueue.QueueHead, pPacket, HTC_PACKET, ListLink) { - if (NULL == pPacket) { + if (!pPacket) { pFoundPacket = pPacket; break; } @@ -1920,7 +1920,7 @@ QDF_STATUS htc_tx_completion_handler(void *Context, do { pPacket = htc_lookup_tx_packet(target, pEndpoint, netbuf); - if (NULL == pPacket) { + if (!pPacket) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC TX lookup failed!\n")); /* may have already been flushed and freed */ diff --git a/htc/htc_services.c b/htc/htc_services.c index 6ee2ed8429..fa0a8010a1 100644 --- a/htc/htc_services.c +++ b/htc/htc_services.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -135,7 +135,7 @@ QDF_STATUS htc_connect_service(HTC_HANDLE HTCHandle, /* allocate a packet to send to the target */ pSendPacket = htc_alloc_control_tx_packet(target); - if (NULL == pSendPacket) { + if (!pSendPacket) { AR_DEBUG_ASSERT(false); status = QDF_STATUS_E_NOMEM; break; @@ -153,7 +153,7 @@ QDF_STATUS htc_connect_service(HTC_HANDLE HTCHandle, pConnectMsg = (HTC_CONNECT_SERVICE_MSG *) qdf_nbuf_data(netbuf); - if (NULL == pConnectMsg) { + if (!pConnectMsg) { AR_DEBUG_ASSERT(0); status = QDF_STATUS_E_FAULT; break; @@ -183,7 +183,7 @@ QDF_STATUS htc_connect_service(HTC_HANDLE HTCHandle, disableCreditFlowCtrl = true; /* check caller if it wants to transfer meta data */ - if ((pConnectReq->pMetaData != NULL) && + if ((pConnectReq->pMetaData) && (pConnectReq->MetaDataLength <= HTC_SERVICE_META_DATA_MAX_LENGTH)) { /* copy meta data into msg buffer (after hdr) */ @@ -282,7 +282,7 @@ QDF_STATUS htc_connect_service(HTC_HANDLE HTCHandle, assignedEndpoint = (HTC_ENDPOINT_ID) rsp_msg_end_id; maxMsgSize = rsp_msg_max_msg_size; - if ((pConnectResp->pMetaData != NULL) && + if ((pConnectResp->pMetaData) && (rsp_msg_serv_meta_len > 0) && (rsp_msg_serv_meta_len <= HTC_SERVICE_META_DATA_MAX_LENGTH)) { @@ -412,7 +412,7 @@ void htc_fw_event_handler(void *context, QDF_STATUS status) struct htc_init_info *initInfo = &target->HTCInitInfo; /* check if target failure handler exists and pass error code to it. */ - if (target->HTCInitInfo.TargetFailure != NULL) + if (target->HTCInitInfo.TargetFailure) initInfo->TargetFailure(initInfo->pContext, status); }