From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: gregkh@linuxfoundation.org
Cc: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 8/9] staging: rtl8192e: Simplify _rtl92e_calculate_bit_shift
Date: Sun, 20 Sep 2015 21:04:32 +0200 [thread overview]
Message-ID: <1442775873-14715-9-git-send-email-mateusz.kulikowski@gmail.com> (raw)
In-Reply-To: <1442775873-14715-1-git-send-email-mateusz.kulikowski@gmail.com>
Use ffs instead of iteration. Behaviour of function doesn't change.
Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
---
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index b3a10f9..0b407fe 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -13,6 +13,7 @@
* wlanfae <wlanfae@realtek.com>
******************************************************************************/
+#include <linux/bitops.h>
#include "rtl_core.h"
#include "r8192E_hw.h"
#include "r8192E_phyreg.h"
@@ -50,13 +51,9 @@ static void _rtl92e_phy_rf_fw_write(struct net_device *dev,
static u32 _rtl92e_calculate_bit_shift(u32 dwBitMask)
{
- u32 i;
-
- for (i = 0; i <= 31; i++) {
- if (((dwBitMask >> i) & 0x1) == 1)
- break;
- }
- return i;
+ if (!dwBitMask)
+ return 32;
+ return ffs(dwBitMask) - 1;
}
u8 rtl92e_is_legal_rf_path(struct net_device *dev, u32 eRFPath)
--
1.8.4.1
next prev parent reply other threads:[~2015-09-20 19:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-20 19:04 [PATCH 0/9] staging: rtl8192e: Various cleanups Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 1/9] staging: rtl8192e: rtl_wx: Fix BRACES warning Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 2/9] staging: rtl8192e: Fix SUSPECT_CODE_INDENT warnings Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 3/9] staging: rtl8192e: Fix CONSTANT_COMPARISON warnings Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 4/9] staging: rtl8192e: Fix FSF_MAILING_ADDRESS warnings Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 5/9] staging: rtl8192e: Remove _rtl92e_silent_reset_mesh Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 6/9] staging: rtl8192e: Remove _rtl92e_dm_check_pbc_gpio Mateusz Kulikowski
2015-09-20 19:04 ` [PATCH 7/9] staging: rtl8192e: Remove extra braces Mateusz Kulikowski
2015-09-20 19:04 ` Mateusz Kulikowski [this message]
2015-09-20 19:04 ` [PATCH 9/9] staging: rtl8192e: Merge/Remove _rtl92e_dm_bb_initialgain_backup Mateusz Kulikowski
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=1442775873-14715-9-git-send-email-mateusz.kulikowski@gmail.com \
--to=mateusz.kulikowski@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®