From patchwork Sat Dec 30 15:44:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10137811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7054460375 for ; Sat, 30 Dec 2017 15:45:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61F9A286CB for ; Sat, 30 Dec 2017 15:45:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55B97286F2; Sat, 30 Dec 2017 15:45:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SBL_CSS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E675B286CB for ; Sat, 30 Dec 2017 15:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=iYMDb+SNvQTcRt9UPtA4b/dHi4nym+2O5rqkNUWZDb0=; b=Syf kaQi5qKVVAR+Rn9wDG5IcCUYZa5DLiWylfRWGEqqeQ8HAKXniNqKl+XlJilm7hQscW20O+Bk9lMgE HOqb9/G4q2fTqx7QTyfnA/5OF1Mq0PQlWmPYkZ01kIDL2Z4NjdhfqjId25KQA8GLNgT4RH/6nj/8L zAfk+g72P384SsHx2VUpa1VAhFsccPa1GyuLpV80IzxrSxakU9rxOluC6yMzvAlSpRynSe217gin8 9geejD9xSz5XG2mPMWwZtMnLz0FiNOFqmmMeXItjLTkZkmv+5xX+mXqD4q7UKwLKCZnQ43eJGj2bI 986fB35db6Uls3n6TO6OmL9nEry3FeA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eVJKD-0004NW-CD; Sat, 30 Dec 2017 15:45:29 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eVJK9-00042W-7s for linux-arm-kernel@lists.infradead.org; Sat, 30 Dec 2017 15:45:27 +0000 Received: by mail-pf0-x243.google.com with SMTP id u19so23159938pfa.12 for ; Sat, 30 Dec 2017 07:45:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=irf/1XTfOhUFpn1pMzG8bY1kDmPGkc05cZIz9pP6HWg=; b=nsM2mtUxorTC1UTdWW0SkxB8P4oIQKqtnr/KmSlMutkL7Vk4l2+5+E+K53Y8endLWT ooWd3xYCmqbfa622CCBvw5gvY9ZyX3dUQpWhdr08IrUL2xFGbk0epi5yTHa31SMw8CJ0 vyLSYihysgtT5AiktulfRCJgrMe1K+1BjfMLVXBhiLIT9+OQFgCTNsEEVzAYiO1lzIQq QJ4AbUYO0pBGpS/qv6J6A30Anzw21tVIA5hfU+ns5lDVNmRpK3O2dB01WvakjiRkvG91 5vutCcu4BwQv5EEB/d2/OMxHVeAYM+QyiGyULm3RSa1fwn+6nIRSZp0jcVRegZYe3mYL MRlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=irf/1XTfOhUFpn1pMzG8bY1kDmPGkc05cZIz9pP6HWg=; b=S4NcbzfdTKIteeMtSj8YtWsq6+VeZIIAqKg3p18++8lURCj0rFrqheoidT1w2ZDMlS BPtbpNJ6fjGEkEytMUX6d/pS9dxEquhqPkQj7fdSzZmH4pCoqLN1b1dNfqH53yzopUNy sUO5LFlx3EP0S0XjnOccYCsx1BQpnyQN2eXFiRgcsEqWACJwNijmz1JLty5CQvIms57a HX36tvUl4Wcal30ble7MHnwKagV8YK5RfMqSRH+BgTMTMyWOJm+Zb5KbQSUaEqHQ8ish EhE+OJW4EWn6sx6i3QjyDwmWkiaMZ/pExwxh3R6ABqigWJSvt271sxL4ix6/VUgh736M Wkmw== X-Gm-Message-State: AKGB3mJRU42ON7QRPQCfIwdLmlOrEl597bDNvqofa7sKyh+nBciQ9Uu1 dNMCVVFsZKsbdc5RQkBIKKo= X-Google-Smtp-Source: ACJfBot+zSYyUFNaAjecJh2uiX3tdtfksu1rnPslYyuSeFAIQjSvRaNvXDbZoW5CA0+DwL3OBqAWYw== X-Received: by 10.99.60.28 with SMTP id j28mr15944891pga.358.1514648714241; Sat, 30 Dec 2017 07:45:14 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id h10sm4051333pgv.26.2017.12.30.07.45.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Dec 2017 07:45:13 -0800 (PST) From: Himanshu Jha To: michael.chan@broadcom.com Subject: [PATCH] ethernet/broadcom: Use zeroing memory allocator than allocator/memset Date: Sat, 30 Dec 2017 21:14:57 +0530 Message-Id: <1514648697-7148-1-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171230_074525_343245_CACFCC15 X-CRM114-Status: UNSURE ( 9.51 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mcgrof@kernel.org, bcm-kernel-feedback-list@broadcom.com, Himanshu Jha , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use dma_zalloc_coherent for allocating zeroed memory and remove unnecessary memset function. Done using Coccinelle. Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci 0-day tested with no failures. Suggested-by: Luis R. Rodriguez Signed-off-by: Himanshu Jha --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 6 ++---- drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index 1fbbbab..14a59e5 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c @@ -2128,27 +2128,25 @@ static int bcm_enetsw_open(struct net_device *dev) /* allocate rx dma ring */ size = priv->rx_ring_size * sizeof(struct bcm_enet_desc); - p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); + p = dma_zalloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); if (!p) { dev_err(kdev, "cannot allocate rx ring %u\n", size); ret = -ENOMEM; goto out_freeirq_tx; } - memset(p, 0, size); priv->rx_desc_alloc_size = size; priv->rx_desc_cpu = p; /* allocate tx dma ring */ size = priv->tx_ring_size * sizeof(struct bcm_enet_desc); - p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); + p = dma_zalloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); if (!p) { dev_err(kdev, "cannot allocate tx ring\n"); ret = -ENOMEM; goto out_free_rx_ring; } - memset(p, 0, size); priv->tx_desc_alloc_size = size; priv->tx_desc_cpu = p; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c index fed37cd..3c746f2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c @@ -278,12 +278,11 @@ static int bnxt_hwrm_set_dcbx_app(struct bnxt *bp, struct dcb_app *app, n = IEEE_8021QAZ_MAX_TCS; data_len = sizeof(*data) + sizeof(*fw_app) * n; - data = dma_alloc_coherent(&bp->pdev->dev, data_len, &mapping, - GFP_KERNEL); + data = dma_zalloc_coherent(&bp->pdev->dev, data_len, &mapping, + GFP_KERNEL); if (!data) return -ENOMEM; - memset(data, 0, data_len); bnxt_hwrm_cmd_hdr_init(bp, &get, HWRM_FW_GET_STRUCTURED_DATA, -1, -1); get.dest_data_addr = cpu_to_le64(mapping); get.structure_id = cpu_to_le16(STRUCT_HDR_STRUCT_ID_DCBX_APP);