Skip to contentSkip to conversation

wifi: mt76: use hrtimer_setup() in mt76x02u beacon init

PATCH In review Mieczyslaw Nalewaj 2 participants 2 messages Apr 20 1 message not in the archive Arm MediaTek

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 wifi: mt76: use hrtimer_setup() in mt76x02u beacon init

Replace the two-step hrtimer initialization pattern with a single consolidated call to hrtimer_setup().
The legacy approach of calling hrtimer_init() followed by manual assignment to timer.function is deprecated. The new hrtimer_setup() helper atomically initializes the timer and assigns the callback function in one operation, eliminating the race-prone intermediate state where the timer is initialized but lacks a handler.

---
 mt76x02_usb_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mt76x02_usb_core.c +2 -2
index c94c2f661..3a28a8cc1 100644
@@ -264,8 +264,8 @@ void mt76x02u_init_beacon_config(struct mt76x02_dev *dev)
 	};
 	dev->beacon_ops = &beacon_ops;
 
-	hrtimer_init(&dev->pre_tbtt_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	dev->pre_tbtt_timer.function = mt76x02u_pre_tbtt_interrupt;
+	hrtimer_setup(&dev->pre_tbtt_timer, mt76x02u_pre_tbtt_interrupt, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	INIT_WORK(&dev->pre_tbtt_work, mt76x02u_pre_tbtt_work);
 
 	mt76x02_init_beacon_config(dev);
Signature · 1 line
2.53.0
#2 lore raw
Quoted 18 lines

Replace the two-step hrtimer initialization pattern with a single consolidated call to hrtimer_setup().
The legacy approach of calling hrtimer_init() followed by manual assignment to timer.function is deprecated. The new hrtimer_setup() helper atomically initializes the timer and assigns the callback function in one operation, eliminating the race-prone intermediate state where the timer is initialized but lacks a handler.

---
 mt76x02_usb_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mt76x02_usb_core.c +0 -0
index c94c2f661..3a28a8cc1 100644

mt76x02_usb_core.c void mt76x02u_init_beacon_config(struct mt76x02_dev *dev) · line 268

Quoted 7 lines
mt76x02_usb_core.c +2 -2
@@ -264,8 +264,8 @@ void mt76x02u_init_beacon_config(struct mt76x02_dev *dev)
 	};
 	dev->beacon_ops = &beacon_ops;
 
-	hrtimer_init(&dev->pre_tbtt_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	dev->pre_tbtt_timer.function = mt76x02u_pre_tbtt_interrupt;
+	hrtimer_setup(&dev->pre_tbtt_timer, mt76x02u_pre_tbtt_interrupt, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);

I guess we are already using hrtimer_setup():
https://github.com/torvalds/linux/blob/master/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c#L267

Regards,
Lorenzo

Quoted 6 lines
mt76x02_usb_core.c +0 -0
 	INIT_WORK(&dev->pre_tbtt_work, mt76x02u_pre_tbtt_work);
 
 	mt76x02_init_beacon_config(dev);
Signature · 1 line
2.53.0