Commit a613f581 authored by Santiago Leon's avatar Santiago Leon Committed by David S. Miller

ibmveth: Remove integer divide caused by modulus

Replace some modulus operators with an increment and compare to avoid
an integer divide.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarSantiago Leon <santil@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a5d31e0f
...@@ -252,7 +252,9 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc ...@@ -252,7 +252,9 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
} }
free_index = pool->consumer_index; 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]; index = pool->free_map[free_index];
ibmveth_assert(index != IBM_VETH_INVALID_MAP); ibmveth_assert(index != IBM_VETH_INVALID_MAP);
...@@ -377,9 +379,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64 ...@@ -377,9 +379,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
free_index = adapter->rx_buff_pool[pool].producer_index; free_index = adapter->rx_buff_pool[pool].producer_index;
adapter->rx_buff_pool[pool].producer_index adapter->rx_buff_pool[pool].producer_index++;
= (adapter->rx_buff_pool[pool].producer_index + 1) if (adapter->rx_buff_pool[pool].producer_index >=
% adapter->rx_buff_pool[pool].size; adapter->rx_buff_pool[pool].size)
adapter->rx_buff_pool[pool].producer_index = 0;
adapter->rx_buff_pool[pool].free_map[free_index] = index; adapter->rx_buff_pool[pool].free_map[free_index] = index;
mb(); mb();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment