Skip to content

Commit c17ffe0

Browse files
martin-kaisergregkh
authored andcommitted
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: Martin Kaiser <[email protected]> Tested-by: Philipp Hortmann <[email protected]> # Edimax N150 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent da8b094 commit c17ffe0

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

drivers/staging/r8188eu/core/rtw_sta_mgt.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
391391
/* any station allocated can be searched by hash list */
392392
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
393393
{
394-
struct list_head *plist, *phead;
395-
struct sta_info *psta = NULL;
394+
struct sta_info *ploop, *psta = NULL;
396395
u32 index;
397396
u8 *addr;
398397
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)
409408

410409
spin_lock_bh(&pstapriv->sta_hash_lock);
411410

412-
phead = &pstapriv->sta_hash[index];
413-
plist = phead->next;
414-
415-
while (phead != plist) {
416-
psta = container_of(plist, struct sta_info, hash_list);
417-
418-
if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) {
419-
/* if found the matched address */
411+
list_for_each_entry(ploop, &pstapriv->sta_hash[index], hash_list) {
412+
if (!memcmp(ploop->hwaddr, addr, ETH_ALEN)) {
413+
psta = ploop;
420414
break;
421415
}
422-
psta = NULL;
423-
plist = plist->next;
424416
}
425417

426418
spin_unlock_bh(&pstapriv->sta_hash_lock);

0 commit comments

Comments
 (0)