aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2006-05-08 18:11:29 -0400
committerStephen Hemminger <shemminger@osdl.org>2006-05-08 19:00:27 -0400
commitcb5d9547307f44f210f88c829bad4249eeb24bc3 (patch)
treea8887e1ff9aaae397309b987bdf9e4bef6080032
parentf55925d7eb04f936ab4c001f10e3e9c74c1297ae (diff)
sky2: use mask instead of modulo operation
Gcc isn't smart enough to know that it can do a modulo operation with power of 2 constant by doing a mask. So add macro to do it for us. Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
-rw-r--r--drivers/net/sky2.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 4bb6ea13efdd..d9cce50cffd1 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -79,6 +79,8 @@
79#define NAPI_WEIGHT 64 79#define NAPI_WEIGHT 64
80#define PHY_RETRIES 1000 80#define PHY_RETRIES 1000
81 81
82#define RING_NEXT(x,s) (((x)+1) & ((s)-1))
83
82static const u32 default_msg = 84static const u32 default_msg =
83 NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK 85 NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
84 | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR 86 | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR
@@ -719,7 +721,7 @@ static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2)
719{ 721{
720 struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; 722 struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod;
721 723
722 sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE; 724 sky2->tx_prod = RING_NEXT(sky2->tx_prod, TX_RING_SIZE);
723 return le; 725 return le;
724} 726}
725 727
@@ -735,7 +737,7 @@ static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
735static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) 737static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2)
736{ 738{
737 struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; 739 struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put;
738 sky2->rx_put = (sky2->rx_put + 1) % RX_LE_SIZE; 740 sky2->rx_put = RING_NEXT(sky2->rx_put, RX_LE_SIZE);
739 return le; 741 return le;
740} 742}
741 743
@@ -1078,7 +1080,7 @@ err_out:
1078/* Modular subtraction in ring */ 1080/* Modular subtraction in ring */
1079static inline int tx_dist(unsigned tail, unsigned head) 1081static inline int tx_dist(unsigned tail, unsigned head)
1080{ 1082{
1081 return (head - tail) % TX_RING_SIZE; 1083 return (head - tail) & (TX_RING_SIZE - 1);
1082} 1084}
1083 1085
1084/* Number of list elements available for next tx */ 1086/* Number of list elements available for next tx */
@@ -1255,7 +1257,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1255 le->opcode = OP_BUFFER | HW_OWNER; 1257 le->opcode = OP_BUFFER | HW_OWNER;
1256 1258
1257 fre = sky2->tx_ring 1259 fre = sky2->tx_ring
1258 + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; 1260 + RING_NEXT((re - sky2->tx_ring) + i, TX_RING_SIZE);
1259 pci_unmap_addr_set(fre, mapaddr, mapping); 1261 pci_unmap_addr_set(fre, mapaddr, mapping);
1260 } 1262 }
1261 1263
@@ -1315,7 +1317,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1315 1317
1316 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 1318 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1317 struct tx_ring_info *fre; 1319 struct tx_ring_info *fre;
1318 fre = sky2->tx_ring + (put + i + 1) % TX_RING_SIZE; 1320 fre = sky2->tx_ring + RING_NEXT(put + i, TX_RING_SIZE);
1319 pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr), 1321 pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr),
1320 skb_shinfo(skb)->frags[i].size, 1322 skb_shinfo(skb)->frags[i].size,
1321 PCI_DMA_TODEVICE); 1323 PCI_DMA_TODEVICE);
@@ -1876,7 +1878,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
1876 break; 1878 break;
1877 opcode &= ~HW_OWNER; 1879 opcode &= ~HW_OWNER;
1878 1880
1879 hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; 1881 hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
1880 le->opcode = 0; 1882 le->opcode = 0;
1881 1883
1882 link = le->link; 1884 link = le->link;