Patchwork rtlwifi/rtl8192c: in _rtl92c_phy_calculate_bit_shift remove comparing bitmask against 1

login
register
mail settings
Submitter Devendra Naga
Date Jan. 31, 2012, 7:11 a.m.
Message ID <1327993863-6810-1-git-send-email-devendra.aaru@gmail.com>
Download mbox | patch
Permalink /patch/138703/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Devendra Naga - Jan. 31, 2012, 7:11 a.m.
From: "Devendra.Naga" <devendra.aaru@gmail.com>

in _rtl92c_phy_calculate_bit_shift everytime the right shifted bitmask
is AND with 1 and compared against 1. i.e.
       if ((bitmask >> i) & 0x1 == 1)
               break;
which in the if condition is anyway becomes a 1 or 0.

Signed-off-by: Devendra.Naga <devendra.aaru@gmail.com>
---
 drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Joe Perches - Jan. 31, 2012, 7:37 a.m.
On Tue, 2012-01-31 at 02:11 -0500, Devendra.Naga wrote:
> From: "Devendra.Naga" <devendra.aaru@gmail.com>
[]
> diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
[]
> @@ -177,7 +177,7 @@ u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask)
>  	u32 i;
>  
>  	for (i = 0; i <= 31; i++) {
> -		if (((bitmask >> i) & 0x1) == 1)
> +		if ((bitmask >> i) & 0x1)
>  			break;
>  	}
>  	return i;

Perhaps this is simpler and faster:

{
	u32 rtn = (u32)ffs((int)bitmask);
	if (rtn)
		return rtn - 1;
	return 32;
}


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
John W. Linville - Feb. 8, 2012, 7:57 p.m.
On Mon, Jan 30, 2012 at 11:37:20PM -0800, Joe Perches wrote:
> On Tue, 2012-01-31 at 02:11 -0500, Devendra.Naga wrote:
> > From: "Devendra.Naga" <devendra.aaru@gmail.com>
> []
> > diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
> []
> > @@ -177,7 +177,7 @@ u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask)
> >  	u32 i;
> >  
> >  	for (i = 0; i <= 31; i++) {
> > -		if (((bitmask >> i) & 0x1) == 1)
> > +		if ((bitmask >> i) & 0x1)
> >  			break;
> >  	}
> >  	return i;
> 
> Perhaps this is simpler and faster:
> 
> {
> 	u32 rtn = (u32)ffs((int)bitmask);
> 	if (rtn)
> 		return rtn - 1;
> 	return 32;
> }

Are you planning to revise your patch based on Joe's suggestion?

Patch

diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
index 22e998d..a76b223 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
@@ -177,7 +177,7 @@  u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask)
 	u32 i;
 
 	for (i = 0; i <= 31; i++) {
-		if (((bitmask >> i) & 0x1) == 1)
+		if ((bitmask >> i) & 0x1)
 			break;
 	}
 	return i;