Commit 6c21da20 authored by Sean Wang's avatar Sean Wang Committed by David S. Miller

net-next: mediatek: improve more with using dma_zalloc_coherent

Improve more in the existing code by reusing dma_zalloc_coherent instead
of dma_alloc_coherent with __GFP_ZERO or superfluous zeroing buffer.
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d1753390
...@@ -605,10 +605,10 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) ...@@ -605,10 +605,10 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
dma_addr_t dma_addr; dma_addr_t dma_addr;
int i; int i;
eth->scratch_ring = dma_alloc_coherent(eth->dev, eth->scratch_ring = dma_zalloc_coherent(eth->dev,
cnt * sizeof(struct mtk_tx_dma), cnt * sizeof(struct mtk_tx_dma),
&eth->phy_scratch_ring, &eth->phy_scratch_ring,
GFP_ATOMIC | __GFP_ZERO); GFP_ATOMIC);
if (unlikely(!eth->scratch_ring)) if (unlikely(!eth->scratch_ring))
return -ENOMEM; return -ENOMEM;
...@@ -623,7 +623,6 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) ...@@ -623,7 +623,6 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
if (unlikely(dma_mapping_error(eth->dev, dma_addr))) if (unlikely(dma_mapping_error(eth->dev, dma_addr)))
return -ENOMEM; return -ENOMEM;
memset(eth->scratch_ring, 0x0, sizeof(struct mtk_tx_dma) * cnt);
phy_ring_tail = eth->phy_scratch_ring + phy_ring_tail = eth->phy_scratch_ring +
(sizeof(struct mtk_tx_dma) * (cnt - 1)); (sizeof(struct mtk_tx_dma) * (cnt - 1));
...@@ -1318,10 +1317,9 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) ...@@ -1318,10 +1317,9 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
return -ENOMEM; return -ENOMEM;
} }
ring->dma = dma_alloc_coherent(eth->dev, ring->dma = dma_zalloc_coherent(eth->dev,
rx_dma_size * sizeof(*ring->dma), rx_dma_size * sizeof(*ring->dma),
&ring->phys, &ring->phys, GFP_ATOMIC);
GFP_ATOMIC | __GFP_ZERO);
if (!ring->dma) if (!ring->dma)
return -ENOMEM; return -ENOMEM;
......
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