Skip to content

Commit cbf5e61

Browse files
committed
wifi: mt76: initialize more wcid fields mt76_wcid_init
Reduces code duplication and ensures that the phy index is always set. Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
1 parent 36e0210 commit cbf5e61

File tree

9 files changed

+18
-31
lines changed

9 files changed

+18
-31
lines changed

drivers/net/wireless/mediatek/mt76/mac80211.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
742742
int ret;
743743

744744
dev_set_drvdata(dev->dev, dev);
745-
mt76_wcid_init(&dev->global_wcid);
745+
mt76_wcid_init(&dev->global_wcid, phy->band_idx);
746746
ret = mt76_phy_init(phy, hw);
747747
if (ret)
748748
return ret;
@@ -1494,11 +1494,10 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
14941494
ewma_signal_init(&wcid->rssi);
14951495
if (phy->band_idx == MT_BAND1)
14961496
mt76_wcid_mask_set(dev->wcid_phy_mask, wcid->idx);
1497-
wcid->phy_idx = phy->band_idx;
14981497
rcu_assign_pointer(dev->wcid[wcid->idx], wcid);
14991498
phy->num_sta++;
15001499

1501-
mt76_wcid_init(wcid);
1500+
mt76_wcid_init(wcid, phy->band_idx);
15021501
out:
15031502
mutex_unlock(&dev->mutex);
15041503

@@ -1588,14 +1587,19 @@ void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
15881587
}
15891588
EXPORT_SYMBOL_GPL(mt76_sta_pre_rcu_remove);
15901589

1591-
void mt76_wcid_init(struct mt76_wcid *wcid)
1590+
void mt76_wcid_init(struct mt76_wcid *wcid, u8 band_idx)
15921591
{
1592+
wcid->hw_key_idx = -1;
1593+
wcid->phy_idx = band_idx;
1594+
15931595
INIT_LIST_HEAD(&wcid->tx_list);
15941596
skb_queue_head_init(&wcid->tx_pending);
15951597
skb_queue_head_init(&wcid->tx_offchannel);
15961598

15971599
INIT_LIST_HEAD(&wcid->list);
15981600
idr_init(&wcid->pktid);
1601+
1602+
INIT_LIST_HEAD(&wcid->poll_list);
15991603
}
16001604
EXPORT_SYMBOL_GPL(mt76_wcid_init);
16011605

drivers/net/wireless/mediatek/mt76/mt76.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ mt76_token_put(struct mt76_dev *dev, int token)
17641764
return txwi;
17651765
}
17661766

1767-
void mt76_wcid_init(struct mt76_wcid *wcid);
1767+
void mt76_wcid_init(struct mt76_wcid *wcid, u8 band_idx);
17681768
void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid);
17691769
void mt76_wcid_add_poll(struct mt76_dev *dev, struct mt76_wcid *wcid);
17701770

drivers/net/wireless/mediatek/mt76/mt7603/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
6666

6767
idx = MT7603_WTBL_RESERVED - 1 - mvif->idx;
6868
dev->mt76.vif_mask |= BIT_ULL(mvif->idx);
69-
INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
7069
mvif->sta.wcid.idx = idx;
71-
mvif->sta.wcid.hw_key_idx = -1;
7270
mvif->sta.vif = mvif;
73-
mt76_wcid_init(&mvif->sta.wcid);
71+
mt76_wcid_init(&mvif->sta.wcid, 0);
7472

7573
eth_broadcast_addr(bc_addr);
7674
mt7603_wtbl_init(dev, idx, mvif->idx, bc_addr);

drivers/net/wireless/mediatek/mt76/mt7615/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
225225

226226
INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
227227
mvif->sta.wcid.idx = idx;
228-
mvif->sta.wcid.phy_idx = mvif->mt76.band_idx;
229-
mvif->sta.wcid.hw_key_idx = -1;
230-
mt76_wcid_init(&mvif->sta.wcid);
228+
mt76_wcid_init(&mvif->sta.wcid, mvif->mt76.band_idx);
231229

232230
mt7615_mac_wtbl_update(dev, idx,
233231
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

drivers/net/wireless/mediatek/mt76/mt76x02_util.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
287287

288288
mvif->idx = idx;
289289
mvif->group_wcid.idx = MT_VIF_WCID(idx);
290-
mvif->group_wcid.hw_key_idx = -1;
291-
mt76_wcid_init(&mvif->group_wcid);
290+
mt76_wcid_init(&mvif->group_wcid, 0);
292291

293292
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
294293
rcu_assign_pointer(dev->mt76.wcid[MT_VIF_WCID(idx)], &mvif->group_wcid);

drivers/net/wireless/mediatek/mt76/mt7915/main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,9 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
253253
}
254254

255255
INIT_LIST_HEAD(&mvif->sta.rc_list);
256-
INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
257256
mvif->sta.wcid.idx = idx;
258-
mvif->sta.wcid.phy_idx = ext_phy;
259-
mvif->sta.wcid.hw_key_idx = -1;
260257
mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
261-
mt76_wcid_init(&mvif->sta.wcid);
258+
mt76_wcid_init(&mvif->sta.wcid, phy->mt76->band_idx);
262259

263260
mt7915_mac_wtbl_update(dev, idx,
264261
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

drivers/net/wireless/mediatek/mt76/mt7921/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
325325

326326
INIT_LIST_HEAD(&mvif->sta.deflink.wcid.poll_list);
327327
mvif->sta.deflink.wcid.idx = idx;
328-
mvif->sta.deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
329-
mvif->sta.deflink.wcid.hw_key_idx = -1;
330328
mvif->sta.deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
331-
mt76_wcid_init(&mvif->sta.deflink.wcid);
329+
mt76_wcid_init(&mvif->sta.deflink.wcid, mvif->bss_conf.mt76.band_idx);
332330

333331
mt7921_mac_wtbl_update(dev, idx,
334332
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

drivers/net/wireless/mediatek/mt76/mt7925/main.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,9 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
378378

379379
idx = MT792x_WTBL_RESERVED - mconf->mt76.idx;
380380

381-
INIT_LIST_HEAD(&mlink->wcid.poll_list);
382381
mlink->wcid.idx = idx;
383-
mlink->wcid.phy_idx = 0;
384-
mlink->wcid.hw_key_idx = -1;
385382
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
386-
mt76_wcid_init(&mlink->wcid);
383+
mt76_wcid_init(&mlink->wcid, 0);
387384

388385
mt7925_mac_wtbl_update(dev, idx,
389386
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
@@ -850,10 +847,9 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
850847
return -ENOSPC;
851848

852849
mconf = mt792x_vif_to_link(mvif, link_id);
853-
INIT_LIST_HEAD(&mlink->wcid.poll_list);
850+
mt76_wcid_init(&mlink->wcid, 0);
854851
mlink->wcid.sta = 1;
855852
mlink->wcid.idx = idx;
856-
mlink->wcid.phy_idx = 0;
857853
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
858854
mlink->last_txs = jiffies;
859855
mlink->wcid.link_id = link_sta->link_id;
@@ -863,7 +859,7 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
863859
wcid = &mlink->wcid;
864860
ewma_signal_init(&wcid->rssi);
865861
rcu_assign_pointer(dev->mt76.wcid[wcid->idx], wcid);
866-
mt76_wcid_init(wcid);
862+
mt76_wcid_init(wcid, 0);
867863
ewma_avg_signal_init(&mlink->avg_ack_signal);
868864
memset(mlink->airtime_ac, 0,
869865
sizeof(msta->deflink.airtime_ac));

drivers/net/wireless/mediatek/mt76/mt7996/main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,9 @@ mt7996_vif_link_add(struct mt7996_phy *phy, struct ieee80211_vif *vif,
214214
idx = MT7996_WTBL_RESERVED - mlink->mt76.idx;
215215

216216
INIT_LIST_HEAD(&mlink->sta.rc_list);
217-
INIT_LIST_HEAD(&mlink->sta.wcid.poll_list);
218217
mlink->sta.wcid.idx = idx;
219-
mlink->sta.wcid.phy_idx = band_idx;
220-
mlink->sta.wcid.hw_key_idx = -1;
221218
mlink->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
222-
mt76_wcid_init(&mlink->sta.wcid);
219+
mt76_wcid_init(&mlink->sta.wcid, band_idx);
223220

224221
mt7996_mac_wtbl_update(dev, idx,
225222
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

0 commit comments

Comments
 (0)