All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k: simplify ATH_EP_RND
@ 2013-02-26 18:41 ` Bob Copeland
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Copeland @ 2013-02-26 18:41 UTC (permalink / raw)
  To: Luis R. Rodriguez, Jouni Malinen, Vasanthakumar Thiagarajan,
	Senthil Balasubramanian
  Cc: linux-wireless, ath9k-devel

Remove the embedded branch to make the ATH_EP_RND macro a little
clearer.  The new version also generates better code, saving 24
bytes of text:

   text	   data	    bss	    dec	    hex	filename
  87858	   1641	     24	  89523	  15db3	ath9k_orig.ko
  87834	   1641	     24	  89499	  15d9b	ath9k_new.ko

Although neither version handles negative values particularly well,
the lone caller clamps all negative values to zero anyway.  I have
verified that the results are the same for the range of possible
positive rssi values.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
 drivers/net/wireless/ath/ath9k/common.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 5f845be..eca95a0 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -40,7 +40,7 @@
 	x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN);  	\
 } while (0)
 #define ATH_EP_RND(x, mul) 						\
-	((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
+	(((x) + ((mul)/2)) / (mul))
 
 int ath9k_cmn_padpos(__le16 frame_control);
 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
-- 
1.7.2.5

-- 
Bob Copeland %% www.bobcopeland.com

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

* [ath9k-devel] [PATCH] ath9k: simplify ATH_EP_RND
@ 2013-02-26 18:41 ` Bob Copeland
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Copeland @ 2013-02-26 18:41 UTC (permalink / raw)
  To: ath9k-devel

Remove the embedded branch to make the ATH_EP_RND macro a little
clearer.  The new version also generates better code, saving 24
bytes of text:

   text	   data	    bss	    dec	    hex	filename
  87858	   1641	     24	  89523	  15db3	ath9k_orig.ko
  87834	   1641	     24	  89499	  15d9b	ath9k_new.ko

Although neither version handles negative values particularly well,
the lone caller clamps all negative values to zero anyway.  I have
verified that the results are the same for the range of possible
positive rssi values.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
 drivers/net/wireless/ath/ath9k/common.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 5f845be..eca95a0 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -40,7 +40,7 @@
 	x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN);  	\
 } while (0)
 #define ATH_EP_RND(x, mul) 						\
-	((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
+	(((x) + ((mul)/2)) / (mul))
 
 int ath9k_cmn_padpos(__le16 frame_control);
 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
-- 
1.7.2.5

-- 
Bob Copeland %% www.bobcopeland.com

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

end of thread, other threads:[~2013-02-26 18:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 18:41 [PATCH] ath9k: simplify ATH_EP_RND Bob Copeland
2013-02-26 18:41 ` [ath9k-devel] " Bob Copeland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.