mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
move mt76_wcid_alloc to core
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
+1
-23
@@ -188,28 +188,6 @@ mt76x2_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
mutex_unlock(&dev->mutex);
|
||||
}
|
||||
|
||||
static int
|
||||
mt76_wcid_alloc(struct mt76x2_dev *dev)
|
||||
{
|
||||
int i, idx = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dev->wcid_mask); i++) {
|
||||
idx = ffs(~dev->wcid_mask[i]);
|
||||
if (!idx)
|
||||
continue;
|
||||
|
||||
idx--;
|
||||
dev->wcid_mask[i] |= BIT(idx);
|
||||
break;
|
||||
}
|
||||
|
||||
idx = i * BITS_PER_LONG + idx;
|
||||
if (idx > 247)
|
||||
return -1;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
static int
|
||||
mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta)
|
||||
@@ -223,7 +201,7 @@ mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
idx = mt76_wcid_alloc(dev);
|
||||
idx = mt76_wcid_alloc(dev->wcid_mask, ARRAY_SIZE(dev->wcid));
|
||||
if (idx < 0) {
|
||||
ret = -ENOSPC;
|
||||
goto out;
|
||||
|
||||
@@ -79,4 +79,26 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__mt76_poll_msec);
|
||||
|
||||
int mt76_wcid_alloc(unsigned long *mask, int size)
|
||||
{
|
||||
int i, idx = 0, cur;
|
||||
|
||||
for (i = 0; i < size / BITS_PER_LONG; i++) {
|
||||
idx = ffs(~mask[i]);
|
||||
if (!idx)
|
||||
continue;
|
||||
|
||||
idx--;
|
||||
cur = i * BITS_PER_LONG + idx;
|
||||
if (cur >= size)
|
||||
break;
|
||||
|
||||
mask[i] |= BIT(idx);
|
||||
return cur;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_wcid_alloc);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
Reference in New Issue
Block a user