diff mbox series

wifi: brcmsmac: use generic lists to manage timers

Message ID 20230703131730.99500-1-dmantipov@yandex.ru
State New
Headers show
Series wifi: brcmsmac: use generic lists to manage timers | expand

Commit Message

Dmitry Antipov July 3, 2023, 1:17 p.m. UTC
Prefer generic lists over ad-hoc quirks to manage
timers, adjust related code.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 .../broadcom/brcm80211/brcmsmac/mac80211_if.c | 35 ++++---------------
 .../broadcom/brcm80211/brcmsmac/mac80211_if.h |  4 +--
 2 files changed, 9 insertions(+), 30 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
index 0bd4e679a359..d5fb47144943 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
@@ -314,8 +314,7 @@  static void brcms_free(struct brcms_info *wl)
 		schedule();
 
 	/* free timers */
-	for (t = wl->timers; t; t = next) {
-		next = t->next;
+	list_for_each_entry_safe(t, next, &wl->timers, list) {
 #ifdef DEBUG
 		kfree(t->name);
 #endif
@@ -1152,6 +1151,8 @@  static struct brcms_info *brcms_attach(struct bcma_device *pdev)
 	spin_lock_init(&wl->lock);
 	spin_lock_init(&wl->isr_lock);
 
+	INIT_LIST_HEAD(&wl->timers);
+
 	/* common load-time initialization */
 	wl->wlc = brcms_c_attach((void *)wl, pdev, unit, false, &err);
 	if (!wl->wlc) {
@@ -1502,8 +1503,7 @@  struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
 	t->wl = wl;
 	t->fn = fn;
 	t->arg = arg;
-	t->next = wl->timers;
-	wl->timers = t;
+	list_add(&t->list, &wl->timers);
 
 #ifdef DEBUG
 	t->name = kstrdup(name, GFP_ATOMIC);
@@ -1561,35 +1561,14 @@  bool brcms_del_timer(struct brcms_timer *t)
  */
 void brcms_free_timer(struct brcms_timer *t)
 {
-	struct brcms_info *wl = t->wl;
-	struct brcms_timer *tmp;
-
 	/* delete the timer in case it is active */
 	brcms_del_timer(t);
 
-	if (wl->timers == t) {
-		wl->timers = wl->timers->next;
+	list_del(&t->list);
 #ifdef DEBUG
-		kfree(t->name);
+	kfree(t->name);
 #endif
-		kfree(t);
-		return;
-
-	}
-
-	tmp = wl->timers;
-	while (tmp) {
-		if (tmp->next == t) {
-			tmp->next = t->next;
-#ifdef DEBUG
-			kfree(t->name);
-#endif
-			kfree(t);
-			return;
-		}
-		tmp = tmp->next;
-	}
-
+	kfree(t);
 }
 
 /*
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.h
index eaf926a96a88..c2c3d90f4ed3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.h
@@ -41,7 +41,7 @@  struct brcms_timer {
 	uint ms;
 	bool periodic;
 	bool set;		/* indicates if timer is active */
-	struct brcms_timer *next;	/* for freeing on unload */
+	struct list_head list;	/* for freeing on unload */
 #ifdef DEBUG
 	char *name;		/* Description of the timer */
 #endif
@@ -75,7 +75,7 @@  struct brcms_info {
 
 	/* timer related fields */
 	atomic_t callbacks;	/* # outstanding callback functions */
-	struct brcms_timer *timers;	/* timer cleanup queue */
+	struct list_head timers;	/* timer cleanup queue */
 
 	struct tasklet_struct tasklet;	/* dpc tasklet */
 	bool resched;		/* dpc needs to be and is rescheduled */