From patchwork Sat Dec 30 15:28:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10137789 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 B5AFD60233 for ; Sat, 30 Dec 2017 15:31:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8BED287A1 for ; Sat, 30 Dec 2017 15:31:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D7AD287A3; Sat, 30 Dec 2017 15:31:14 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51CF4287A1 for ; Sat, 30 Dec 2017 15:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751321AbdL3PaT (ORCPT ); Sat, 30 Dec 2017 10:30:19 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:42354 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751177AbdL3PaQ (ORCPT ); Sat, 30 Dec 2017 10:30:16 -0500 Received: by mail-pf0-f196.google.com with SMTP id d23so23162957pfe.9; Sat, 30 Dec 2017 07:30:16 -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:in-reply-to:references; bh=+cUxIQoF8WjEEA11uuewJCdceJLBLEmR+/PoIqGn4/o=; b=XVnNZInCmkRvbPWifLpxZkXSVmIBy2qyCaIXYfxjUWfm1JfVm9Q5gw8p+MsIsmFhLz wOlvJF5BakqanK4EYF3pzwdcN1fN4fLQbjLqDRTvaDcbFeLgWeoTuhv2jpfXVi2seT93 cM4mDuGtcER7e3oooRuCQxT/kSS+RZLzxUBymKAgtZoAKDgsYbvR/kSqhYA0kuotPkXm A2bqj66dMW2fvw57mQi4nCdZRVm0vYySKX18B4pwiWxxaVDLd5/y2SqCwJF8nkw5X6AQ LYFvt6Qm0BLuH5H0hiVz1Nn/mytk80I68RVoRgRRTcfTvn2PI/8DJ5OKsqYh5lteiw4C /6Tg== 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:in-reply-to :references; bh=+cUxIQoF8WjEEA11uuewJCdceJLBLEmR+/PoIqGn4/o=; b=HCG5rsJyIUVzeGnd25pPInAudWGpDyKRlDNTKO44UYJUTs8bDAMLlIV+0UBup05LH9 e1WGXAEpHNQYtlH9MP5jvRwRg7hLQtgB9sucsRPKYVtMxxn7mOi2N97Gs2K2vE32ne3o HWkJWL+OEhXw4vY+gnGUjOOMSSTe0ArcOi4wmJ1vAyEcP4L0IT0srNTvpsIlzaJ4MIyw B2tBZ85MkN9NQuegeu0U6//ZlKXi3X0nbw4cPwpCIboDMFOCoNAoQg5cUVeBfnoPYuvy noVoMH8hwJY1pDk3karOGtDMKlgg6Jo478QQin1uNKG5h70kdpl+Vpn4c5USR4upbxGY sE3g== X-Gm-Message-State: AKGB3mLmmn/v2qt8X3bS/H040KasE66uuFBIRRICPfzQ3QDYapzHnBzd UhwFoKX59GbRKoYkYYIqt+4= X-Google-Smtp-Source: ACJfBosUVdLgBXiMgl9UwFr/YEll0qK7oIsfuVn0wuU5vIE4UI4EIIhng9QBDMIlHhj81GL+zVo2UQ== X-Received: by 10.98.17.72 with SMTP id z69mr37648882pfi.86.1514647816093; Sat, 30 Dec 2017 07:30:16 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id f79sm81933715pfd.45.2017.12.30.07.30.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Dec 2017 07:30:15 -0800 (PST) From: Himanshu Jha To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, aacraid@adaptec.com Cc: anil.gurumurthy@qlogic.com, sudarsana.kalluru@qlogic.com, QLogic-Storage-Upstream@qlogic.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, QLogic-Storage-Upstream@cavium.com, qla2xxx-upstream@qlogic.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Himanshu Jha Subject: [PATCH 6/9] scsi: dpt_i2o: Use zeroing allocator rather than allocator/memset Date: Sat, 30 Dec 2017 20:58:29 +0530 Message-Id: <1514647712-6332-7-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514647712-6332-1-git-send-email-himanshujha199640@gmail.com> References: <1514647712-6332-1-git-send-email-himanshujha199640@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use dma_zalloc_coherent instead of dma_alloc_coherent followed by memset 0. Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci Suggested-by: Luis R. Rodriguez Signed-off-by: Himanshu Jha --- drivers/scsi/dpt_i2o.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs (hba_count) * sizeof(struct i2o_sys_tbl_entry); - sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, - sys_tbl_len, &sys_tbl_pa, GFP_KERNEL); + sys_tbl = dma_zalloc_coherent(&pHba->pDev->dev, sys_tbl_len, + &sys_tbl_pa, GFP_KERNEL); if (!sys_tbl) { printk(KERN_WARNING "SysTab Set failed. Out of memory.\n"); return -ENOMEM; } - memset(sys_tbl, 0, sys_tbl_len); sys_tbl->num_entries = hba_count; sys_tbl->version = I2OVERSION; diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index fd172b0..67cd777 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -1371,13 +1371,12 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) schedule_timeout_uninterruptible(1); } while (m == EMPTY_QUEUE); - status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); + status = dma_zalloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); if(status == NULL) { adpt_send_nop(pHba, m); printk(KERN_ERR"IOP reset failed - no free memory.\n"); return -ENOMEM; } - memset(status,0,4); msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0; msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID; @@ -2827,14 +2826,13 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) msg=(u32 __iomem *)(pHba->msg_addr_virt+m); - status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); + status = dma_zalloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); if (!status) { adpt_send_nop(pHba, m); printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n", pHba->name); return -ENOMEM; } - memset(status, 0, 4); writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]); writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]); @@ -2881,14 +2879,14 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) pHba->reply_pool, pHba->reply_pool_pa); } - pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev, - pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, - &pHba->reply_pool_pa, GFP_KERNEL); + pHba->reply_pool = dma_zalloc_coherent(&pHba->pDev->dev, + pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, + &pHba->reply_pool_pa, GFP_KERNEL); if (!pHba->reply_pool) { printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name); return -ENOMEM; } - memset(pHba->reply_pool, 0 , pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4); for(i = 0; i < pHba->reply_fifo_size; i++) { writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4), @@ -3117,13 +3115,12 @@ static int adpt_i2o_build_sys_table(void)