Thread (22 messages) 22 messages, 5 authors, 2011-11-21

Re: [PATCH 13/13] ath5k: Optimize ath5k_cw_validate

From: Bob Copeland <me@bobcopeland.com>
Date: 2011-11-20 16:14:42

On Sun, Nov 20, 2011 at 09:56:28AM +0200, Nick Kossifidis wrote:
+	/* Check if cw_req + 1 a power of 2 */
+	if (!((cw_req + 1) & cw_req))
+		return cw_req;
+
+	/* Check if cw_req is a power of 2 */
+	if (!(cw_req & (cw_req - 1)))
+		return cw_req - 1;
There's is_power_of_two() in log2.h .. but this whole thing could also
be something like roundup_pow_of_two(cw) maybe?

-- 
Bob Copeland %% www.bobcopeland.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help