From 23017c8842d2b067e3d6ff927e10af61cd65f3a0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 28 Apr 2021 09:35:22 -0700 Subject: staging: rtl8188eu: Use list iterators and helpers The rtl8188eu manually re-implements list helper functions and macros in various ways. Replace with existing list helpers. The following coccinelle script was used to convert the code. @@ identifier v1, v2, v3, v4; symbol next; expression e; iterator name list_for_each; statement S; @@ <+... ( - e = v1->next; | - e = get_next(v1); ) ... when != e - while ( \( v1 != e \| e != v1 \) ) + list_for_each (e, v1) { ... - v2 = container_of(e, struct v3, v4); + v2 = list_entry(e, struct v3, v4); ?- if (!v2) S ... ( - e = e->next; | - e = get_next(e); ) ... when != e } ...+> @@ identifier v1, v2, v3, v4; symbol next; expression e; iterator name list_for_each; statement S; @@ <+... ( - e = v1->next; | - e = get_next(v1); ) ... when != e - while (1) + list_for_each (e, v1) { - if ( \( e == v1 \| v1 == e \) ) - break; ... - v2 = container_of(e, struct v3, v4); + v2 = list_entry(e, struct v3, v4); ?- if (!v2) S ... ( - e = e->next; | - e = get_next(e); ) ... when != e } ...+> Manually fixed up formatting, and added autoremoved comments back in. Compile tested only. Signed-off-by: Guenter Roeck Link: https://lore.kernel.org/r/20210428163522.129189-1-linux@roeck-us.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/staging/rtl8188eu/os_dep/xmit_linux.c') diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index a9c42fb80583..6935bdb2d7d2 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -118,13 +118,9 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = phead->next; - /* free sta asoc_queue */ - while (phead != plist) { - psta = container_of(plist, struct sta_info, asoc_list); - - plist = plist->next; + list_for_each(plist, phead) { + psta = list_entry(plist, struct sta_info, asoc_list); /* avoid come from STA1 and send back STA1 */ if (!memcmp(psta->hwaddr, &skb->data[6], 6)) -- cgit v1.2.3 From de7711881eb45463f01e467b21256c5e5417b39d Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Tue, 15 Jun 2021 01:14:54 +0100 Subject: staging: rtl8188eu: remove all DBG_88E calls from os_dep/xmit_linux.c Remove all DBG_88E calls from os_dep/xmit_linux.c as this macro is unnecessary, and many of these calls are dubious in terms of necessity. Removing all calls will ultimately allow the removal of the macro itself. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210615001507.1171-16-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/staging/rtl8188eu/os_dep/xmit_linux.c') diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 6935bdb2d7d2..c73f94651e93 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -26,10 +26,8 @@ int rtw_os_xmit_resource_alloc(struct xmit_buf *pxmitbuf, u32 alloc_sz) for (i = 0; i < 8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); - if (!pxmitbuf->pxmit_urb[i]) { - DBG_88E("pxmitbuf->pxmit_urb[i]==NULL"); + if (!pxmitbuf->pxmit_urb[i]) return _FAIL; - } } return _SUCCESS; } @@ -132,16 +130,12 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) memcpy(newskb->data, psta->hwaddr, 6); res = rtw_xmit(padapter, &newskb); if (res < 0) { - DBG_88E("%s()-%d: rtw_xmit() return error!\n", - __func__, __LINE__); pxmitpriv->tx_drop++; dev_kfree_skb_any(newskb); } else { pxmitpriv->tx_pkts++; } } else { - DBG_88E("%s-%d: skb_copy() failed!\n", - __func__, __LINE__); pxmitpriv->tx_drop++; spin_unlock_bh(&pstapriv->asoc_list_lock); -- cgit v1.2.3 From 887af3fa7195c68e3341b23dd1c1e69311d69504 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 25 Jun 2021 01:07:35 +0100 Subject: staging: rtl8188eu: remove all RT_TRACE calls from os_dep/xmit_linux.c Remove all RT_TRACE calls from os_dep/xmit_linux.c as this macro is unnecessary, and these calls are dubious in terms of necessity. Removing all calls will ultimately allow the removal of the macro itself. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210625000756.6313-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'drivers/staging/rtl8188eu/os_dep/xmit_linux.c') diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index c73f94651e93..1b5776ae8eba 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -159,13 +159,8 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); - - if (!rtw_if_up(padapter)) { - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, - ("%s: rtw_if_up fail\n", __func__)); + if (!rtw_if_up(padapter)) goto drop_packet; - } rtw_check_xmit_resource(padapter, pkt); @@ -184,16 +179,11 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) goto drop_packet; pxmitpriv->tx_pkts++; - RT_TRACE(_module_xmit_osdep_c_, _drv_info_, - ("%s: tx_pkts=%d\n", __func__, (u32)pxmitpriv->tx_pkts)); goto exit; drop_packet: pxmitpriv->tx_drop++; dev_kfree_skb_any(pkt); - RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, - ("%s: drop, tx_drop=%d\n", __func__, (u32)pxmitpriv->tx_drop)); - exit: return NETDEV_TX_OK; } -- cgit v1.2.3