Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openwrt/mt76.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-12-21 00:40:53 +0300
committerFelix Fietkau <nbd@openwrt.org>2015-12-21 00:40:53 +0300
commitb9484962c74f33e811b958e61d645d7172a5a87b (patch)
treee99c4387b661a1a0e2af1d23273ccd45c9283502 /util.c
parent93db8eede4a15cd81f3be20d6174ad46ca6262e0 (diff)
move mt76_wcid_alloc to core
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'util.c')
-rw-r--r--util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util.c b/util.c
index 0b490691..01fc5ab0 100644
--- a/util.c
+++ b/util.c
@@ -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");