Skip to contentSkip to conversation

ath9k: simplify ATH_EP_RND

PATCH New Bob Copeland 1 participant 1 message Feb 26, 2013 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: simplify ATH_EP_RND

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.

---
 drivers/net/wireless/ath/ath9k/common.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/common.h +1 -1
index 5f845be..eca95a0 100644
@@ -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);
Signature · 4 lines
1.7.2.5

-- 
Bob Copeland %% www.bobcopeland.com