Skip to contentSkip to conversation

staging: rtl8712: use list_for_each_entry in function r8712_get_oldest_wlan_network

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

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v5 3/4 staging: rtl8712: use list_for_each_entry in function r8712_get_oldest_wlan_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 | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +2 -7
index ad9b1a23abeb..6b352f8436ba 100644
@@ -276,23 +276,18 @@ static int is_same_network(struct wlan_bssid_ex *src,
 struct	wlan_network *r8712_get_oldest_wlan_network(
 				struct  __queue *scanned_queue)
 {
-	struct list_head *plist, *phead;
+	struct list_head *phead;
 	struct	wlan_network	*pwlan = NULL;
 	struct	wlan_network	*oldest = NULL;
 
 	phead = &scanned_queue->queue;
-	plist = phead->next;
-	while (1) {
-		if (end_of_queue_search(phead, plist) ==  true)
-			break;
-		pwlan = container_of(plist, struct wlan_network, list);
+	list_for_each_entry(pwlan, phead, list) {
 		if (pwlan->fixed != true) {
 			if (oldest == NULL ||
 			    time_after((unsigned long)oldest->last_scanned,
 			    (unsigned long)pwlan->last_scanned))
 				oldest = pwlan;
 		}
-		plist = plist->next;
 	}
 	return oldest;
 }
Signature · 1 line
2.17.1