From: Nick Kossifidis <mickflemm@gmail.com>
To: ath5k-devel@lists.ath5k.org, linux-wireless@vger.kernel.org
Cc: linville@tuxdriver.com, me@bobcopeland.com, mcgrof@gmail.com,
nbd@openwrt.org, jirislaby@gmail.com,
Nick Kossifidis <mickflemm@gmail.com>
Subject: [PATCH 13/13] ath5k: Optimize ath5k_cw_validate
Date: Sun, 20 Nov 2011 09:56:28 +0200 [thread overview]
Message-ID: <1321775788-12520-14-git-send-email-mickflemm@gmail.com> (raw)
In-Reply-To: <1321775788-12520-1-git-send-email-mickflemm@gmail.com>
Optimize ath5k_cw_validate by using the classic (X & (X - 1)) == 0
check to see if a number is power of 2.
Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
---
drivers/net/wireless/ath/ath5k/qcu.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c
index e50e64d..cdbaad7 100644
--- a/drivers/net/wireless/ath/ath5k/qcu.c
+++ b/drivers/net/wireless/ath/ath5k/qcu.c
@@ -111,6 +111,16 @@ ath5k_cw_validate(u16 cw_req)
u32 cw = 1;
cw_req = min(cw_req, (u16)1023);
+ /* 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;
+
+ /* If none of the above is correct
+ * find the closest power of 2 */
while (cw < cw_req)
cw = (cw << 1) | 1;
--
1.7.8.rc1
next prev parent reply other threads:[~2011-11-20 7:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-20 7:56 [PATCH 00/13] ath5k: A few updates + cleanups + kerneldoc Nick Kossifidis
2011-11-20 7:56 ` [PATCH 01/13] ath5k: Switch from read-and-clear to write-to-clear method when handling PISR/SISR registers Nick Kossifidis
2011-11-20 7:56 ` [PATCH 02/13] ath5k: Maintain PISR snapshot Nick Kossifidis
2011-11-20 22:43 ` Adrian Chadd
2011-11-21 3:44 ` Nick Kossifidis
2011-11-20 7:56 ` [PATCH 03/13] ath5k: Add TXNOFRM to INT_TX_ALL Nick Kossifidis
2011-11-20 7:56 ` [PATCH 04/13] ath5k: Cleanups v1 Nick Kossifidis
2011-11-20 7:56 ` [PATCH 05/13] ath5k: Calibration re-work Nick Kossifidis
2011-11-20 7:56 ` [PATCH 06/13] ath5k: Use usleep_range where possible Nick Kossifidis
2011-11-20 9:23 ` Felix Fietkau
2011-11-20 15:43 ` Nick Kossifidis
2011-11-20 16:01 ` Jiri Slaby
2011-11-20 16:10 ` Nick Kossifidis
2011-11-20 7:56 ` [PATCH 07/13] ath5k: Cleanups v2 + add kerneldoc on all hw functions Nick Kossifidis
2011-11-20 7:56 ` [PATCH 08/13] ath5k: We always do full calibration on AR5210 Nick Kossifidis
2011-11-20 7:56 ` [PATCH 09/13] ath5k: Add a module parameter to disable hw rf kill switch Nick Kossifidis
2011-11-20 7:56 ` [PATCH 10/13] ath5k: MRR support and 2GHz radio override belong in ah_capabilities Nick Kossifidis
2011-11-20 7:56 ` [PATCH 11/13] ath5k: ath5k_ani_period_restart only touches struct ath5k_ani_state Nick Kossifidis
2011-11-20 7:56 ` [PATCH 12/13] ath5k: Renumber hw queue ids Nick Kossifidis
2011-11-20 7:56 ` Nick Kossifidis [this message]
2011-11-20 15:44 ` [PATCH 13/13] ath5k: Optimize ath5k_cw_validate Bob Copeland
2011-11-20 16:15 ` Nick Kossifidis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321775788-12520-14-git-send-email-mickflemm@gmail.com \
--to=mickflemm@gmail.com \
--cc=ath5k-devel@lists.ath5k.org \
--cc=jirislaby@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mcgrof@gmail.com \
--cc=me@bobcopeland.com \
--cc=nbd@openwrt.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox