Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1293971
| From | Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/1] mac80211: improve the contiguous mask checking |
| Date | 2015-12-17 16:10 +0100 |
| Message-ID | <qGIlP-154-9@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
If the result of adding the first set bit to the mask is power of 2,
the mask must be contiguous. "mask & -mask" can get the first set bit
of mask gracefully.
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
net/mac80211/iface.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index c9e325d..4c896e8 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1628,7 +1628,9 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
- if (__ffs64(mask) + hweight64(mask) != fls64(mask)) {
+ inc = (mask & -mask);
+ val = mask + inc;
+ if ((val & (val - 1)) != 0) {
/* not a contiguous mask ... not handled now! */
pr_info("not contiguous\n");
break;
@@ -1649,7 +1651,6 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
- inc = 1ULL<<__ffs64(mask);
val = (start & mask);
addr = (start & ~mask) | (val & mask);
do {
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 1/1] mac80211: improve the contiguous mask checking Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2015-12-17 16:10 +0100
csiph-web