Skip to content

Commit

Permalink
ibmveth: Remove integer divide caused by modulus
Browse files Browse the repository at this point in the history
Replace some modulus operators with an increment and compare to avoid
an integer divide.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Santiago Leon <santil@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Santiago Leon authored and David S. Miller committed Sep 7, 2010
1 parent a5d31e0 commit a613f58
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/net/ibmveth.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
}

free_index = pool->consumer_index;
pool->consumer_index = (pool->consumer_index + 1) % pool->size;
pool->consumer_index++;
if (pool->consumer_index >= pool->size)
pool->consumer_index = 0;
index = pool->free_map[free_index];

ibmveth_assert(index != IBM_VETH_INVALID_MAP);
Expand Down Expand Up @@ -377,9 +379,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
DMA_FROM_DEVICE);

free_index = adapter->rx_buff_pool[pool].producer_index;
adapter->rx_buff_pool[pool].producer_index
= (adapter->rx_buff_pool[pool].producer_index + 1)
% adapter->rx_buff_pool[pool].size;
adapter->rx_buff_pool[pool].producer_index++;
if (adapter->rx_buff_pool[pool].producer_index >=
adapter->rx_buff_pool[pool].size)
adapter->rx_buff_pool[pool].producer_index = 0;
adapter->rx_buff_pool[pool].free_map[free_index] = index;

mb();
Expand Down

0 comments on commit a613f58

Please sign in to comment.