From 7923b287d972a43b4253ed51a5d42296c766aa60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 4 Mar 2015 17:18:31 +0100 Subject: [PATCH] wifi_drv: fix find_next_bit function Among others, this function is used in the for_each_set_big() macro, which is used when configuring the data rate tables. Therefore, this fixes observed performance issues. Fixes #1439. --- repos/dde_linux/src/lib/wifi/lxcc_emul.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/repos/dde_linux/src/lib/wifi/lxcc_emul.cc b/repos/dde_linux/src/lib/wifi/lxcc_emul.cc index e3487835d..70abb7478 100644 --- a/repos/dde_linux/src/lib/wifi/lxcc_emul.cc +++ b/repos/dde_linux/src/lib/wifi/lxcc_emul.cc @@ -1486,20 +1486,14 @@ void put_page(struct page *page) unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { - unsigned long i, j; + unsigned long i = offset / BITS_PER_LONG; + offset -= (i * BITS_PER_LONG); - for (i = offset; i < (size / BITS_PER_LONG); i++) - if (addr[i] == ~0UL) - break; + for (; offset < size; offset++) + if (addr[i] & (1UL << offset)) + return offset; - if (i == size) - return size; - - for (j = 0; j < BITS_PER_LONG; j++) - if ((addr[i]) & (1UL << j)) - break; - - return (i * BITS_PER_LONG) + j; + return size; }