[PATCH 2/7] staging: r8188eu: simplify rtw_alloc_xmitframe

From: Martin Kaiser
Date: Tue Feb 07 2023 - 14:23:37 EST


Make the rtw_alloc_xmitframe function a bit simpler.

The container_of() call never returns NULL. The if (pxframe) check is
false only if pfree_xmit_queue is empty. Handle this special case
explicitly and save one level of indentation.

Signed-off-by: Martin Kaiser <martin@xxxxxxxxx>
---
drivers/staging/r8188eu/core/rtw_xmit.c | 40 +++++++++++--------------
1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index 4d6210d89533..6ec342b726f9 100644
--- a/drivers/staging/r8188eu/core/rtw_xmit.c
+++ b/drivers/staging/r8188eu/core/rtw_xmit.c
@@ -1256,38 +1256,32 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf

spin_lock_bh(&pfree_xmit_queue->lock);

- if (list_empty(&pfree_xmit_queue->queue)) {
- pxframe = NULL;
- } else {
- phead = get_list_head(pfree_xmit_queue);
-
- plist = phead->next;
+ if (list_empty(&pfree_xmit_queue->queue))
+ goto out;

- pxframe = container_of(plist, struct xmit_frame, list);
-
- list_del_init(&pxframe->list);
- }
+ phead = get_list_head(pfree_xmit_queue);
+ plist = phead->next;
+ pxframe = container_of(plist, struct xmit_frame, list);
+ list_del_init(&pxframe->list);

- if (pxframe) { /* default value setting */
- pxmitpriv->free_xmitframe_cnt--;
+ pxmitpriv->free_xmitframe_cnt--;

- pxframe->buf_addr = NULL;
- pxframe->pxmitbuf = NULL;
+ pxframe->buf_addr = NULL;
+ pxframe->pxmitbuf = NULL;

- memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib));
- /* pxframe->attrib.psta = NULL; */
+ memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib));
+ /* pxframe->attrib.psta = NULL; */

- pxframe->frame_tag = DATA_FRAMETAG;
+ pxframe->frame_tag = DATA_FRAMETAG;

- pxframe->pkt = NULL;
- pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */
+ pxframe->pkt = NULL;
+ pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */

- pxframe->agg_num = 1;
- pxframe->ack_report = 0;
- }
+ pxframe->agg_num = 1;
+ pxframe->ack_report = 0;

+out:
spin_unlock_bh(&pfree_xmit_queue->lock);
-
return pxframe;
}

--
2.30.2