mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
mt76: fix wcid allocation issues
mt76 core uses ffs() to find the next free bit. This works well for 32 bit architectures where BITS_PER_LONG is 32. ffs only checks 32 bit values, so allocation fails on 64 bit architectures. Additionally, the wcid mask array was too small in cases where the array was not a multiple of BITS_PER_LONG. Fix this by making the wcid mask array u32 instead and use DIV_ROUND_UP for the size, just in case we ever bump it to a value that's not a multiple of 32. Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
@@ -42,17 +42,17 @@ 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 mt76_wcid_alloc(u32 *mask, int size)
|
||||
{
|
||||
int i, idx = 0, cur;
|
||||
|
||||
for (i = 0; i < DIV_ROUND_UP(size, BITS_PER_LONG); i++) {
|
||||
for (i = 0; i < DIV_ROUND_UP(size, 32); i++) {
|
||||
idx = ffs(~mask[i]);
|
||||
if (!idx)
|
||||
continue;
|
||||
|
||||
idx--;
|
||||
cur = i * BITS_PER_LONG + idx;
|
||||
cur = i * 32 + idx;
|
||||
if (cur >= size)
|
||||
break;
|
||||
|
||||
@@ -74,13 +74,13 @@ int mt76_get_min_avg_rssi(struct mt76_dev *dev, bool ext_phy)
|
||||
rcu_read_lock();
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dev->wcid_mask); i++) {
|
||||
unsigned long mask = dev->wcid_mask[i];
|
||||
unsigned long phy_mask = dev->wcid_phy_mask[i];
|
||||
u32 mask = dev->wcid_mask[i];
|
||||
u32 phy_mask = dev->wcid_phy_mask[i];
|
||||
|
||||
if (!mask)
|
||||
continue;
|
||||
|
||||
for (j = i * BITS_PER_LONG; mask; j++, mask >>= 1, phy_mask >>= 1) {
|
||||
for (j = i * 32; mask; j++, mask >>= 1, phy_mask >>= 1) {
|
||||
if (!(mask & 1))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user