net: bcmgenet: cleanup for bcmgenet_xmit_frag()
authorPetri Gynther <pgynther@google.com>
Tue, 5 Apr 2016 21:00:00 +0000 (14:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Apr 2016 23:33:51 +0000 (19:33 -0400)
Add frag_size = skb_frag_size(frag) and use it when needed.

Signed-off-by: Petri Gynther <pgynther@google.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/genet/bcmgenet.c

index 7f85a8494eeed4eade03c22c8258e12da8af92e4..d77cd6dee0922ffef0772a82042dd8d7e356845e 100644 (file)
@@ -1331,6 +1331,7 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
        struct bcmgenet_priv *priv = netdev_priv(dev);
        struct device *kdev = &priv->pdev->dev;
        struct enet_cb *tx_cb_ptr;
+       unsigned int frag_size;
        dma_addr_t mapping;
        int ret;
 
@@ -1338,10 +1339,12 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
 
        if (unlikely(!tx_cb_ptr))
                BUG();
+
        tx_cb_ptr->skb = NULL;
 
-       mapping = skb_frag_dma_map(kdev, frag, 0,
-                                  skb_frag_size(frag), DMA_TO_DEVICE);
+       frag_size = skb_frag_size(frag);
+
+       mapping = skb_frag_dma_map(kdev, frag, 0, frag_size, DMA_TO_DEVICE);
        ret = dma_mapping_error(kdev, mapping);
        if (ret) {
                priv->mib.tx_dma_failed++;
@@ -1351,10 +1354,10 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
        }
 
        dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
-       dma_unmap_len_set(tx_cb_ptr, dma_len, frag->size);
+       dma_unmap_len_set(tx_cb_ptr, dma_len, frag_size);
 
        dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping,
-                   (frag->size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
+                   (frag_size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
                    (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT));
 
        return 0;