Commit c17ffe00 authored by Martin Kaiser's avatar Martin Kaiser Committed by Greg Kroah-Hartman

staging: r8188eu: replace hand coded loop with list_for_each_entry

In function rtw_get_stainfo, we can use list_for_each_entry to iterate
over the list of stations and make the code a bit simpler.
Signed-off-by: default avatarMartin Kaiser <martin@kaiser.cx>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Link: https://lore.kernel.org/r/20230211170223.419205-1-martin@kaiser.cxSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da8b0946
...@@ -391,8 +391,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) ...@@ -391,8 +391,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
/* any station allocated can be searched by hash list */ /* any station allocated can be searched by hash list */
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
{ {
struct list_head *plist, *phead; struct sta_info *ploop, *psta = NULL;
struct sta_info *psta = NULL;
u32 index; u32 index;
u8 *addr; u8 *addr;
u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
...@@ -409,18 +408,11 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) ...@@ -409,18 +408,11 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
spin_lock_bh(&pstapriv->sta_hash_lock); spin_lock_bh(&pstapriv->sta_hash_lock);
phead = &pstapriv->sta_hash[index]; list_for_each_entry(ploop, &pstapriv->sta_hash[index], hash_list) {
plist = phead->next; if (!memcmp(ploop->hwaddr, addr, ETH_ALEN)) {
psta = ploop;
while (phead != plist) {
psta = container_of(plist, struct sta_info, hash_list);
if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) {
/* if found the matched address */
break; break;
} }
psta = NULL;
plist = plist->next;
} }
spin_unlock_bh(&pstapriv->sta_hash_lock); spin_unlock_bh(&pstapriv->sta_hash_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment