Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1613120imm; Fri, 27 Jul 2018 22:38:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfRYBydGBN+6DCYtx7N46gUiZRoFYXT1/Tv9V+LhawnvIhCzbINRMOjfUG1gdLWTJTBJ5yo X-Received: by 2002:a63:416:: with SMTP id 22-v6mr8639144pge.229.1532756285237; Fri, 27 Jul 2018 22:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532756285; cv=none; d=google.com; s=arc-20160816; b=YGgbXihHIHFuO/5QnsDiev3UIiTiG2vcPNJX0v3N88dtarFVPd58sgGqk+q1maG46R JOajb+P781rUOWkdP8BCFa6y3IA01q+XtnqgjAqwFk5Jm7XfCm0zzZnlmNfQTl7kvZtZ aLTtulGc60xmU9MXwjSWz2IWaIDGy/EbNMzGcQon5DlaGzyLsExPwaIJPmA3+wLQ2AOA 72rQ1GgDcxef9oLe2bu/qA8zy7VcgNeVgaAdtU0mASZE/VmrX7NocReaM+/D6KDWs2zO ZIAfK7d0lSPjXPurIVM2/hqD2wljmbhwh478h34/Wonss15l5dfuK8kKkAK5Op2ygw3s t6SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=M4Zw5rqK2IQhqyWwVkp2lSvbHJvab41E2rCQVLYiDcQ=; b=Bjpc0778NIARIzoWLqt88yYfc+Ycs6IdDl/Ru5C6CzrpokSZxItyqFCclVKKCM+1+f 8wq79LWzZz/I30IWq+C1sByYWPqKJmRQ8A+D+MzHWh7edFOMoO1qRQ4B4RLaai2sB14z 78Stym3LeGwZaCN3zg0RCCHKEdCBcl7ksM7la7SVvFL+qNQIKT4X+YjJgWcHtPTCVgc3 VK6ZTHsoo2vNrxGELLEMHvrB+frta3TVpR+9a1oLSZKAMSvHs4AiFJjSn6+Uj0GXQdEY pHqvtyTORnnclhx55P00lms5ugSiQstiXbJNiLr3n72ahmAcp0v/bSd/sDqjLRWrX1aF ArRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11-v6si4860274plk.513.2018.07.27.22.37.38; Fri, 27 Jul 2018 22:38:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726228AbeG1HBW (ORCPT + 99 others); Sat, 28 Jul 2018 03:01:22 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:22107 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726047AbeG1HBV (ORCPT ); Sat, 28 Jul 2018 03:01:21 -0400 X-UUID: 9220d135df184609b7a35b44ec2a0dea-20180728 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 284816014; Sat, 28 Jul 2018 13:36:06 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sat, 28 Jul 2018 13:36:03 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Sat, 28 Jul 2018 13:35:58 +0800 From: To: , CC: , , , , Sean Wang Subject: [PATCH net-next 1/2] net-next: mediatek: improve more with using dma_zalloc_coherent Date: Sat, 28 Jul 2018 13:35:55 +0800 Message-ID: <658dfd485c035cdae5452bc5d572125076b47a48.1532755541.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Wang 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: Sean Wang --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index c30aea2..8c85a4b 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -605,10 +605,10 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) dma_addr_t dma_addr; int i; - eth->scratch_ring = dma_alloc_coherent(eth->dev, - cnt * sizeof(struct mtk_tx_dma), - ð->phy_scratch_ring, - GFP_ATOMIC | __GFP_ZERO); + eth->scratch_ring = dma_zalloc_coherent(eth->dev, + cnt * sizeof(struct mtk_tx_dma), + ð->phy_scratch_ring, + GFP_ATOMIC); if (unlikely(!eth->scratch_ring)) return -ENOMEM; @@ -623,7 +623,6 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) if (unlikely(dma_mapping_error(eth->dev, dma_addr))) return -ENOMEM; - memset(eth->scratch_ring, 0x0, sizeof(struct mtk_tx_dma) * cnt); phy_ring_tail = eth->phy_scratch_ring + (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) return -ENOMEM; } - ring->dma = dma_alloc_coherent(eth->dev, - rx_dma_size * sizeof(*ring->dma), - &ring->phys, - GFP_ATOMIC | __GFP_ZERO); + ring->dma = dma_zalloc_coherent(eth->dev, + rx_dma_size * sizeof(*ring->dma), + &ring->phys, GFP_ATOMIC); if (!ring->dma) return -ENOMEM; -- 2.7.4