Skip to contentSkip to conversation

staging: rtl8712: use list_for_each_entry in function update_current_network

PATCH RESEND New Himadri Pandya 1 participant 1 message Apr 5, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v5 4/4 staging: rtl8712: use list_for_each_entry in function update_current_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.

The patch also removes a pointer variable of type list_head as it is no longer needed while using list_for_each.

---
Changes in V5:
- Use list_for_each_entry and remove a pointer variable
Changes in V4:
- Change log message
Changes in V3:
- Improve log message

---
 drivers/staging/rtl8712/rtl871x_mlme.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +3 -12
index 6b352f8436ba..e1c58a49da35 100644
@@ -346,7 +346,7 @@ static void update_current_network(struct _adapter *adapter,
 static void update_scanned_network(struct _adapter *adapter,
 			    struct wlan_bssid_ex *target)
 {
-	struct list_head *plist, *phead;
+	struct list_head *phead;
 
 	u32 bssid_ex_sz;
 	struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
@@ -355,28 +355,19 @@ static void update_scanned_network(struct _adapter *adapter,
 	struct wlan_network *oldest = NULL;
 
 	phead = &queue->queue;
-	plist = phead->next;
-
-	while (1) {
-		if (end_of_queue_search(phead, plist))
-			break;
-
-		pnetwork = container_of(plist, struct wlan_network, list);
+	list_for_each_entry(pnetwork, phead, list) {
 		if (is_same_network(&pnetwork->network, target))
 			break;
 		if ((oldest == ((struct wlan_network *)0)) ||
 		    time_after((unsigned long)oldest->last_scanned,
 				(unsigned long)pnetwork->last_scanned))
 			oldest = pnetwork;
-
-		plist = plist->next;
 	}
 
-
 	/* If we didn't find a match, then get a new network slot to initialize
 	 * with this beacon's information
 	 */
-	if (end_of_queue_search(phead, plist)) {
+	if (end_of_queue_search(phead, phead->next)) {
 		if (list_empty(&pmlmepriv->free_bss_pool.queue)) {
 			/* If there are no more slots, expire the oldest */
 			pnetwork = oldest;
Signature · 1 line
2.17.1