staging: rtl8712: use list_for_each_entry
v5 cover staging: rtl8712: use list_for_each_entry
This patchset replaces while loops with list_for_each_entry macro for traversing linked lists.
V5:
- use list_for_each_entry for list traversals
V4:
- use list_entry instead of container_of
V3:
- improve log message with more explanation about the proposed changes
Himadri Pandya (4):
staging: rtl8712: use list_for_each_entry in function
_r8712_find_network
staging: rtl8712: use list_for_each_entry in function
_free_network_queue
staging: rtl8712: use list_for_each_entry in function
r8712_get_oldest_wlan_network staging: rtl8712: use list_for_each_entry in function
update_current_network
drivers/staging/rtl8712/rtl871x_mlme.c | 39 +++++++------------------- 1 file changed, 10 insertions(+), 29 deletions(-)
Signature · 1 line
2.17.1
PATCH RESEND v5 1/4 staging: rtl8712: use list_for_each_entry in function _r8712_find_network
wlan_network is a list structure. We can avoid using next fileds and comparison to head of the list in order to iterate over it. Instead list_for_each_entry macro can be used to do this more tidily.
---
Changes in V5:
- Use list_for_each_entry
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +3 -5
@@ -133,17 +133,15 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, u8 *addr) {unsigned long irqL; -struct list_head *phead, *plist; +struct list_head *phead;struct wlan_network *pnetwork =NULL ;if (is_zero_ether_addr (addr))return NULL ;spin_lock_irqsave (&scanned_queue->lock, irqL); phead = &scanned_queue->queue; - plist = phead->next; -while (plist != phead) { - pnetwork = container_of(plist, struct wlan_network, list); - plist = plist->next; + +list_for_each_entry (pnetwork, phead, list) {if (!memcmp (addr, pnetwork->network.MacAddress,ETH_ALEN ))break ; }
Signature · 1 line
2.17.1
PATCH RESEND v5 2/4 staging: rtl8712: use list_for_each_entry in function _free_network_queue
In reply to Himadri Pandyawlan_network is a list structure. We can avoid using next fileds and comparison to head of the list in order to iterate over it. Instead list_for_each_entry macro can be used to do this more tidily.
---
Changes in V5:
- Use list_for_each_entry
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +2 -5
@@ -152,17 +152,14 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue,static void _free_network_queue (struct _adapter *padapter) {unsigned long irqL; -struct list_head *phead, *plist; +struct list_head *phead;struct wlan_network *pnetwork;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;struct __queue *scanned_queue = &pmlmepriv->scanned_queue;spin_lock_irqsave (&scanned_queue->lock, irqL); phead = &scanned_queue->queue; - plist = phead->next; -while (!end_of_queue_search (phead, plist)) { - pnetwork = container_of(plist, struct wlan_network, list); - plist = plist->next; +list_for_each_entry (pnetwork, phead, list) {_free_network (pmlmepriv, pnetwork); }spin_unlock_irqrestore (&scanned_queue->lock, irqL);
Signature · 1 line
2.17.1