Skip to content

Commit ede23fa

Browse files
JoePerchesdavem330
authored andcommitted
drivers:net: Convert dma_alloc_coherent(...__GFP_ZERO) to dma_zalloc_coherent
__GFP_ZERO is an uncommon flag and perhaps is better not used. static inline dma_zalloc_coherent exists so convert the uses of dma_alloc_coherent with __GFP_ZERO to the more common kernel style with zalloc. Remove memset from the static inline dma_zalloc_coherent and add just one use of __GFP_ZERO instead. Trivially reduces the size of the existing uses of dma_zalloc_coherent. Realign arguments as appropriate. Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent afe4fd0 commit ede23fa

31 files changed

Lines changed: 135 additions & 153 deletions

File tree

‎drivers/net/ethernet/aeroflex/greth.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,18 +1464,18 @@ static int greth_of_probe(struct platform_device *ofdev)
14641464
}
14651465

14661466
/* Allocate TX descriptor ring in coherent memory */
1467-
greth->tx_bd_base = dma_alloc_coherent(greth->dev, 1024,
1468-
&greth->tx_bd_base_phys,
1469-
GFP_KERNEL | __GFP_ZERO);
1467+
greth->tx_bd_base = dma_zalloc_coherent(greth->dev, 1024,
1468+
&greth->tx_bd_base_phys,
1469+
GFP_KERNEL);
14701470
if (!greth->tx_bd_base) {
14711471
err = -ENOMEM;
14721472
goto error3;
14731473
}
14741474

14751475
/* Allocate RX descriptor ring in coherent memory */
1476-
greth->rx_bd_base = dma_alloc_coherent(greth->dev, 1024,
1477-
&greth->rx_bd_base_phys,
1478-
GFP_KERNEL | __GFP_ZERO);
1476+
greth->rx_bd_base = dma_zalloc_coherent(greth->dev, 1024,
1477+
&greth->rx_bd_base_phys,
1478+
GFP_KERNEL);
14791479
if (!greth->rx_bd_base) {
14801480
err = -ENOMEM;
14811481
goto error4;

‎drivers/net/ethernet/broadcom/bcm63xx_enet.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,7 @@ static int bcm_enet_open(struct net_device *dev)
948948

949949
/* allocate rx dma ring */
950950
size = priv->rx_ring_size * sizeof(struct bcm_enet_desc);
951-
p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma,
952-
GFP_KERNEL | __GFP_ZERO);
951+
p = dma_zalloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL);
953952
if (!p) {
954953
ret = -ENOMEM;
955954
goto out_freeirq_tx;
@@ -960,8 +959,7 @@ static int bcm_enet_open(struct net_device *dev)
960959

961960
/* allocate tx dma ring */
962961
size = priv->tx_ring_size * sizeof(struct bcm_enet_desc);
963-
p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma,
964-
GFP_KERNEL | __GFP_ZERO);
962+
p = dma_zalloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL);
965963
if (!p) {
966964
ret = -ENOMEM;
967965
goto out_free_rx_ring;

‎drivers/net/ethernet/broadcom/bnx2.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,8 @@ bnx2_alloc_mem(struct bnx2 *bp)
853853
bp->status_stats_size = status_blk_size +
854854
sizeof(struct statistics_block);
855855

856-
status_blk = dma_alloc_coherent(&bp->pdev->dev, bp->status_stats_size,
857-
&bp->status_blk_mapping,
858-
GFP_KERNEL | __GFP_ZERO);
856+
status_blk = dma_zalloc_coherent(&bp->pdev->dev, bp->status_stats_size,
857+
&bp->status_blk_mapping, GFP_KERNEL);
859858
if (status_blk == NULL)
860859
goto alloc_mem_err;
861860

‎drivers/net/ethernet/broadcom/bnx2x/bnx2x.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,9 +2069,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
20692069
void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
20702070
bool is_pf);
20712071

2072-
#define BNX2X_ILT_ZALLOC(x, y, size) \
2073-
x = dma_alloc_coherent(&bp->pdev->dev, size, y, \
2074-
GFP_KERNEL | __GFP_ZERO)
2072+
#define BNX2X_ILT_ZALLOC(x, y, size) \
2073+
x = dma_zalloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL)
20752074

20762075
#define BNX2X_ILT_FREE(x, y, size) \
20772076
do { \

‎drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ extern int int_mode;
5151

5252
#define BNX2X_PCI_ALLOC(x, y, size) \
5353
do { \
54-
x = dma_alloc_coherent(&bp->pdev->dev, size, y, \
55-
GFP_KERNEL | __GFP_ZERO); \
54+
x = dma_zalloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
5655
if (x == NULL) \
5756
goto alloc_mem_err; \
5857
DP(NETIF_MSG_HW, "BNX2X_PCI_ALLOC: Physical %Lx Virtual %p\n", \

‎drivers/net/ethernet/broadcom/tg3.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8591,10 +8591,10 @@ static int tg3_mem_rx_acquire(struct tg3 *tp)
85918591
if (!i && tg3_flag(tp, ENABLE_RSS))
85928592
continue;
85938593

8594-
tnapi->rx_rcb = dma_alloc_coherent(&tp->pdev->dev,
8595-
TG3_RX_RCB_RING_BYTES(tp),
8596-
&tnapi->rx_rcb_mapping,
8597-
GFP_KERNEL | __GFP_ZERO);
8594+
tnapi->rx_rcb = dma_zalloc_coherent(&tp->pdev->dev,
8595+
TG3_RX_RCB_RING_BYTES(tp),
8596+
&tnapi->rx_rcb_mapping,
8597+
GFP_KERNEL);
85988598
if (!tnapi->rx_rcb)
85998599
goto err_out;
86008600
}
@@ -8643,21 +8643,20 @@ static int tg3_alloc_consistent(struct tg3 *tp)
86438643
{
86448644
int i;
86458645

8646-
tp->hw_stats = dma_alloc_coherent(&tp->pdev->dev,
8647-
sizeof(struct tg3_hw_stats),
8648-
&tp->stats_mapping,
8649-
GFP_KERNEL | __GFP_ZERO);
8646+
tp->hw_stats = dma_zalloc_coherent(&tp->pdev->dev,
8647+
sizeof(struct tg3_hw_stats),
8648+
&tp->stats_mapping, GFP_KERNEL);
86508649
if (!tp->hw_stats)
86518650
goto err_out;
86528651

86538652
for (i = 0; i < tp->irq_cnt; i++) {
86548653
struct tg3_napi *tnapi = &tp->napi[i];
86558654
struct tg3_hw_status *sblk;
86568655

8657-
tnapi->hw_status = dma_alloc_coherent(&tp->pdev->dev,
8658-
TG3_HW_STATUS_SIZE,
8659-
&tnapi->status_mapping,
8660-
GFP_KERNEL | __GFP_ZERO);
8656+
tnapi->hw_status = dma_zalloc_coherent(&tp->pdev->dev,
8657+
TG3_HW_STATUS_SIZE,
8658+
&tnapi->status_mapping,
8659+
GFP_KERNEL);
86618660
if (!tnapi->hw_status)
86628661
goto err_out;
86638662

‎drivers/net/ethernet/emulex/benet/be_main.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ static int be_queue_alloc(struct be_adapter *adapter, struct be_queue_info *q,
145145
q->len = len;
146146
q->entry_size = entry_size;
147147
mem->size = len * entry_size;
148-
mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, &mem->dma,
149-
GFP_KERNEL | __GFP_ZERO);
148+
mem->va = dma_zalloc_coherent(&adapter->pdev->dev, mem->size, &mem->dma,
149+
GFP_KERNEL);
150150
if (!mem->va)
151151
return -ENOMEM;
152152
return 0;
@@ -2642,8 +2642,8 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
26422642
memset(mac, 0, ETH_ALEN);
26432643

26442644
cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config);
2645-
cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
2646-
GFP_KERNEL | __GFP_ZERO);
2645+
cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
2646+
GFP_KERNEL);
26472647
if (cmd.va == NULL)
26482648
return -1;
26492649

@@ -3946,9 +3946,9 @@ static int be_ctrl_init(struct be_adapter *adapter)
39463946
memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox));
39473947

39483948
rx_filter->size = sizeof(struct be_cmd_req_rx_filter);
3949-
rx_filter->va = dma_alloc_coherent(&adapter->pdev->dev, rx_filter->size,
3950-
&rx_filter->dma,
3951-
GFP_KERNEL | __GFP_ZERO);
3949+
rx_filter->va = dma_zalloc_coherent(&adapter->pdev->dev,
3950+
rx_filter->size, &rx_filter->dma,
3951+
GFP_KERNEL);
39523952
if (rx_filter->va == NULL) {
39533953
status = -ENOMEM;
39543954
goto free_mbox;
@@ -3994,8 +3994,8 @@ static int be_stats_init(struct be_adapter *adapter)
39943994
/* BE3 and Skyhawk */
39953995
cmd->size = sizeof(struct be_cmd_req_get_stats_v1);
39963996

3997-
cmd->va = dma_alloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma,
3998-
GFP_KERNEL | __GFP_ZERO);
3997+
cmd->va = dma_zalloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma,
3998+
GFP_KERNEL);
39993999
if (cmd->va == NULL)
40004000
return -1;
40014001
return 0;

‎drivers/net/ethernet/faraday/ftgmac100.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,9 @@ static int ftgmac100_alloc_buffers(struct ftgmac100 *priv)
778778
{
779779
int i;
780780

781-
priv->descs = dma_alloc_coherent(priv->dev,
782-
sizeof(struct ftgmac100_descs),
783-
&priv->descs_dma_addr,
784-
GFP_KERNEL | __GFP_ZERO);
781+
priv->descs = dma_zalloc_coherent(priv->dev,
782+
sizeof(struct ftgmac100_descs),
783+
&priv->descs_dma_addr, GFP_KERNEL);
785784
if (!priv->descs)
786785
return -ENOMEM;
787786

‎drivers/net/ethernet/faraday/ftmac100.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,10 @@ static int ftmac100_alloc_buffers(struct ftmac100 *priv)
732732
{
733733
int i;
734734

735-
priv->descs = dma_alloc_coherent(priv->dev,
736-
sizeof(struct ftmac100_descs),
737-
&priv->descs_dma_addr,
738-
GFP_KERNEL | __GFP_ZERO);
735+
priv->descs = dma_zalloc_coherent(priv->dev,
736+
sizeof(struct ftmac100_descs),
737+
&priv->descs_dma_addr,
738+
GFP_KERNEL);
739739
if (!priv->descs)
740740
return -ENOMEM;
741741

‎drivers/net/ethernet/ibm/emac/mal.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,8 @@ static int mal_probe(struct platform_device *ofdev)
637637
bd_size = sizeof(struct mal_descriptor) *
638638
(NUM_TX_BUFF * mal->num_tx_chans +
639639
NUM_RX_BUFF * mal->num_rx_chans);
640-
mal->bd_virt = dma_alloc_coherent(&ofdev->dev, bd_size, &mal->bd_dma,
641-
GFP_KERNEL | __GFP_ZERO);
640+
mal->bd_virt = dma_zalloc_coherent(&ofdev->dev, bd_size, &mal->bd_dma,
641+
GFP_KERNEL);
642642
if (mal->bd_virt == NULL) {
643643
err = -ENOMEM;
644644
goto fail_unmap;

0 commit comments

Comments
 (0)