linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] b43: make finding the most significant bit common function
@ 2010-01-14 12:21 Rafał Miłecki
  2010-01-14 23:06 ` Michael Buesch
  0 siblings, 1 reply; 2+ messages in thread
From: Rafał Miłecki @ 2010-01-14 12:21 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org, John W. Linville
  Cc: bcm43xx-dev@lists.berlios.de


Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
  drivers/net/wireless/b43/phy_common.c |   14 ++++++++++++++
  drivers/net/wireless/b43/phy_common.h |    1 +
  drivers/net/wireless/b43/phy_lp.c     |   17 ++---------------
  3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 75b26e1..1389ab2 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -421,3 +421,17 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on)
  {
  	b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4);
  }
+
+/* Find the position of the most significant bit */
+u8 phy_nbits(s32 val)
+{
+	u32 tmp = abs(val);
+	u8 nbits = 0;
+
+	while (tmp != 0) {
+		nbits++;
+		tmp >>= 1;
+	}
+
+	return nbits;
+}
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 9edd4e8..332ba4c 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -418,5 +418,6 @@ int b43_phy_shm_tssi_read(struct b43_wldev *dev, u16 shm_offset);
   */
  void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on);

+u8 phy_nbits(s32 val);

  #endif /* LINUX_B43_PHY_COMMON_H_ */
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index c4e9c5c..7ad9215 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -1593,19 +1593,6 @@ static const struct lpphy_rx_iq_comp lpphy_rev2plus_iq_comp = {
  	.c0 = 0,
  };

-static u8 lpphy_nbits(s32 val)
-{
-	u32 tmp = abs(val);
-	u8 nbits = 0;
-
-	while (tmp != 0) {
-		nbits++;
-		tmp >>= 1;
-	}
-
-	return nbits;
-}
-
  static int lpphy_calc_rx_iq_comp(struct b43_wldev *dev, u16 samples)
  {
  	struct lpphy_iq_est iq_est;
@@ -1632,8 +1619,8 @@ static int lpphy_calc_rx_iq_comp(struct b43_wldev *dev, u16 samples)
  		goto out;
  	}

-	prod_msb = lpphy_nbits(prod);
-	q_msb = lpphy_nbits(qpwr);
+	prod_msb = phy_nbits(prod);
+	q_msb = phy_nbits(qpwr);
  	tmp1 = prod_msb - 20;

  	if (tmp1 >= 0) {
-- 
1.6.4.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] b43: make finding the most significant bit common function
  2010-01-14 12:21 [PATCH 1/2] b43: make finding the most significant bit common function Rafał Miłecki
@ 2010-01-14 23:06 ` Michael Buesch
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Buesch @ 2010-01-14 23:06 UTC (permalink / raw)
  To: bcm43xx-dev
  Cc: Rafał Miłecki, linux-wireless@vger.kernel.org,
	John W. Linville

On Thursday 14 January 2010 13:21:27 Rafał Miłecki wrote:
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>   drivers/net/wireless/b43/phy_common.c |   14 ++++++++++++++
>   drivers/net/wireless/b43/phy_common.h |    1 +
>   drivers/net/wireless/b43/phy_lp.c     |   17 ++---------------
>   3 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
> index 75b26e1..1389ab2 100644
> --- a/drivers/net/wireless/b43/phy_common.c
> +++ b/drivers/net/wireless/b43/phy_common.c
> @@ -421,3 +421,17 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on)
>   {
>   	b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4);
>   }
> +
> +/* Find the position of the most significant bit */
> +u8 phy_nbits(s32 val)
> +{
> +	u32 tmp = abs(val);
> +	u8 nbits = 0;
> +
> +	while (tmp != 0) {
> +		nbits++;
> +		tmp >>= 1;
> +	}
> +
> +	return nbits;
> +}

We already have fls() in bitops.h
I think the following call would be equivalent:

x = fls(abs(val));

So we don't need our own implementation in phy_common.c.
Just use the standard funcs.

-- 
Greetings, Michael.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-14 23:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-14 12:21 [PATCH 1/2] b43: make finding the most significant bit common function Rafał Miłecki
2010-01-14 23:06 ` Michael Buesch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).