net: systemport: Simplify circular pointer arithmetic
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 23 Mar 2017 17:36:48 +0000 (10:36 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Mar 2017 19:53:15 +0000 (12:53 -0700)
Similar to c298ede2fe21 ("net: bcmgenet: simplify circular pointer
arithmetic") we don't need to complex arthimetic since we always have a
ring size that is a power of 2.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bcmsysport.c

index c915bcfae0af6627850e3e988979fe12f1661ebb..61e26c6b26abccb0b3d62e0e01b27c348cbb685f 100644 (file)
@@ -682,11 +682,7 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
                p_index = rdma_readl(priv, RDMA_CONS_INDEX);
        p_index &= RDMA_PROD_INDEX_MASK;
 
-       if (p_index < priv->rx_c_index)
-               to_process = (RDMA_CONS_INDEX_MASK + 1) -
-                       priv->rx_c_index + p_index;
-       else
-               to_process = p_index - priv->rx_c_index;
+       to_process = (p_index - priv->rx_c_index) & RDMA_CONS_INDEX_MASK;
 
        netif_dbg(priv, rx_status, ndev,
                  "p_index=%d rx_c_index=%d to_process=%d\n",