ethernet: remove redundant memset
authorFuqian Huang <huangfq.daxian@gmail.com>
Mon, 15 Jul 2019 03:19:11 +0000 (11:19 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Jul 2019 18:06:27 +0000 (11:06 -0700)
kvzalloc already zeroes the memory during the allocation.
pci_alloc_consistent calls dma_alloc_coherent directly.
In commit 518a2f1925c3
("dma-mapping: zero memory returned from dma_alloc_*"),
dma_alloc_coherent has already zeroed the memory.
So the memset after these function is not needed.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 files changed:
drivers/net/ethernet/atheros/atlx/atl1.c
drivers/net/ethernet/atheros/atlx/atl2.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/chelsio/cxgb4/sched.c
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/jme.c
drivers/net/ethernet/marvell/skge.c
drivers/net/ethernet/mellanox/mlx4/eq.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
drivers/net/ethernet/mellanox/mlxsw/pci.c
drivers/net/ethernet/neterion/s2io.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
drivers/net/ethernet/ti/tlan.c

index 7c767ce9aafae5c7a76d66cc1ed089deaf4b22f5..b5c6dc914720d067fc6bd121cb05fe406d405b54 100644 (file)
@@ -1060,8 +1060,6 @@ static s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
                goto err_nomem;
        }
 
-       memset(ring_header->desc, 0, ring_header->size);
-
        /* init TPD ring */
        tpd_ring->dma = ring_header->dma;
        offset = (tpd_ring->dma & 0x7) ? (8 - (ring_header->dma & 0x7)) : 0;
index 3a3fb5ce0fee3a44121ccbdf2a5a252a4377538c..3aba383227172222cc6b0e553676ee421237a92c 100644 (file)
@@ -291,7 +291,6 @@ static s32 atl2_setup_ring_resources(struct atl2_adapter *adapter)
                &adapter->ring_dma);
        if (!adapter->ring_vir_addr)
                return -ENOMEM;
-       memset(adapter->ring_vir_addr, 0, adapter->ring_size);
 
        /* Init TXD Ring */
        adapter->txd_dma = adapter->ring_dma ;
index 3f632028eff035b66aa1c3206b98a144374b351f..1069eb01cc55e061eb18ecf769f9c098cf2822db 100644 (file)
@@ -2677,8 +2677,6 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
                        mapping = txr->tx_push_mapping +
                                sizeof(struct tx_push_bd);
                        txr->data_mapping = cpu_to_le64(mapping);
-
-                       memset(txr->tx_push, 0, sizeof(struct tx_push_bd));
                }
                qidx = bp->tc_to_qidx[j];
                ring->queue_id = bp->q_info[qidx].queue_id;
index ba6c153ee45c3d8b75283e6b955f62373136f66b..60218dc676a8e3b5949314a6d90f654fb2c65524 100644 (file)
@@ -207,7 +207,6 @@ static int t4_sched_queue_bind(struct port_info *pi, struct ch_sched_queue *p)
                goto out_err;
 
        /* Bind queue to specified class */
-       memset(qe, 0, sizeof(*qe));
        qe->cntxt_id = qid;
        memcpy(&qe->param, p, sizeof(qe->param));
 
index 9d459ccf251dd5e37cae0f566a5cf9491a40df02..e5610a4da5390d705b82bc6ca71231b2c4beb088 100644 (file)
@@ -3144,8 +3144,6 @@ static int fec_enet_init(struct net_device *ndev)
                return -ENOMEM;
        }
 
-       memset(cbd_base, 0, bd_size);
-
        /* Get the Ethernet address */
        fec_get_mac(ndev);
        /* make sure MAC we just acquired is programmed into the hw */
index 76b7b7b85e3540827f8fecd351e92e9e33e76702..0b668357db4dd24de638dd8a995790f482d9b95f 100644 (file)
@@ -582,11 +582,6 @@ jme_setup_tx_resources(struct jme_adapter *jme)
        if (unlikely(!(txring->bufinf)))
                goto err_free_txring;
 
-       /*
-        * Initialize Transmit Descriptors
-        */
-       memset(txring->alloc, 0, TX_RING_ALLOC_SIZE(jme->tx_ring_size));
-
        return 0;
 
 err_free_txring:
index 35a92fd2cf3948eb692d4c6a21ead1ce74d6768f..9ac854c2b3718507d90738cb0de4018339040763 100644 (file)
@@ -2558,8 +2558,6 @@ static int skge_up(struct net_device *dev)
                goto free_pci_mem;
        }
 
-       memset(skge->mem, 0, skge->mem_size);
-
        err = skge_ring_alloc(&skge->rx_ring, skge->mem, skge->dma);
        if (err)
                goto free_pci_mem;
index a5be27772b8ed47951704ec881eb7e267013bcf1..c790a5fcea73a248583edb2fa871bdb087802b84 100644 (file)
@@ -1013,8 +1013,6 @@ static int mlx4_create_eq(struct mlx4_dev *dev, int nent,
 
                dma_list[i] = t;
                eq->page_list[i].map = t;
-
-               memset(eq->page_list[i].buf, 0, PAGE_SIZE);
        }
 
        eq->eqn = mlx4_bitmap_alloc(&priv->eq_table.bitmap);
index 3b04d8927fb1a408cf5f34ae78f7282658ba874e..1f3891fde2eb171be76294b45aefcfab57f9990e 100644 (file)
@@ -2450,7 +2450,6 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
        MLX5_SET(query_vport_counter_in, in, vport_number, vport->vport);
        MLX5_SET(query_vport_counter_in, in, other_vport, 1);
 
-       memset(out, 0, outlen);
        err = mlx5_cmd_exec(esw->dev, in, sizeof(in), out, outlen);
        if (err)
                goto free_out;
index 957d9b09dc3fe1291aa0eb17e39d9501e30dcb97..089ae4d48a82dda15e47c49530f9a4e513577acb 100644 (file)
@@ -1134,7 +1134,6 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports)
        }
 
        /* create send-to-vport group */
-       memset(flow_group_in, 0, inlen);
        MLX5_SET(create_flow_group_in, flow_group_in, match_criteria_enable,
                 MLX5_MATCH_MISC_PARAMETERS);
 
@@ -1293,8 +1292,6 @@ static int esw_create_vport_rx_group(struct mlx5_eswitch *esw, int nvports)
                return -ENOMEM;
 
        /* create vport rx group */
-       memset(flow_group_in, 0, inlen);
-
        esw_set_flow_group_source_port(esw, flow_group_in);
 
        MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, 0);
index 051b19388a812b0ceca68ac5efe7822f52e3a2e4..615455a21567f085671770cb8c2c406fef8d2463 100644 (file)
@@ -847,7 +847,6 @@ static int mlxsw_pci_queue_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
                                             &mem_item->mapaddr);
        if (!mem_item->buf)
                return -ENOMEM;
-       memset(mem_item->buf, 0, mem_item->size);
 
        q->elem_info = kcalloc(q->count, sizeof(*q->elem_info), GFP_KERNEL);
        if (!q->elem_info) {
index 3b2ae1a21678697304684c4bb54fc4af030cd088..e0b2bf3279053ca48ee6d7f0051e9216ad825fad 100644 (file)
@@ -747,7 +747,6 @@ static int init_shared_mem(struct s2io_nic *nic)
                                return -ENOMEM;
                        }
                        mem_allocated += size;
-                       memset(tmp_v_addr, 0, size);
 
                        size = sizeof(struct rxd_info) *
                                rxd_count[nic->rxd_mode];
index 433052f734eddf7ab736d04456fd892b84341a98..5e9f8ee998000682ebf71d5675d976901a04af2d 100644 (file)
@@ -442,10 +442,8 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
                goto out_free_rq;
        }
 
-       memset(rq_addr, 0, rq_size);
        prq = rq_addr;
 
-       memset(rsp_addr, 0, rsp_size);
        prsp = rsp_addr;
 
        prq->host_rsp_dma_addr = cpu_to_le64(rsp_phys_addr);
@@ -755,7 +753,6 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
                return -ENOMEM;
        }
 
-       memset(addr, 0, sizeof(struct netxen_ring_ctx));
        recv_ctx->hwctx = addr;
        recv_ctx->hwctx->ctx_id = cpu_to_le32(port);
        recv_ctx->hwctx->cmd_consumer_offset =
index b4ab1a5f6cd027f082d64a171aabb78020cc7f26..78f0f2d59e227e754fd584cbb39d7a6d8796d650 100644 (file)
@@ -855,7 +855,6 @@ static int tlan_init(struct net_device *dev)
                       dev->name);
                return -ENOMEM;
        }
-       memset(priv->dma_storage, 0, dma_size);
        priv->rx_list = (struct tlan_list *)
                ALIGN((unsigned long)priv->dma_storage, 8);
        priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8);