From patchwork Sat Dec 30 15:28:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10137799 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 7479260233 for ; Sat, 30 Dec 2017 15:31:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68107287A1 for ; Sat, 30 Dec 2017 15:31:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CF2B287A3; Sat, 30 Dec 2017 15:31:54 +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 DF9A9287A1 for ; Sat, 30 Dec 2017 15:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbdL3P3m (ORCPT ); Sat, 30 Dec 2017 10:29:42 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43082 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbdL3P3j (ORCPT ); Sat, 30 Dec 2017 10:29:39 -0500 Received: by mail-pf0-f196.google.com with SMTP id e3so23160541pfi.10; Sat, 30 Dec 2017 07:29:39 -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=DvmHn2vgR1JD1l6R9GK6R1a3bQsMI1dvW+zEC/t6ulk=; b=EHYocUCP8iF+MhHQwGl75VNSkyKo9nJOzMvrvJh7/etHvrDX/UdBbRrJQVKDYy3/jJ gmH8m+583EXSVV0wP9fn1hBg5dwNquhN6/fu8hGTr10Zm51E8n/Sg58bzXB3mlVJR7g1 7lt60HtxInEXu/v98L4UNSS00lzXEAj7t7eL4lqd8pBp3sw2rfYIXY0GvRl7MRnDy/Hh zZTRkY5InEm+7HvCbVVDrZaCx4q2JsBVB7mc2S7Wt/+qgWWfqA702RjBx8GTzBd/4i0E bkVDHYLH1wlygVAzsl6LgXVbQnIhBgzVhD5EyR+V5tFMBvJpesQScZ3x1ZH499tnkior oiaw== 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=DvmHn2vgR1JD1l6R9GK6R1a3bQsMI1dvW+zEC/t6ulk=; b=lJNyl+UWxZdS2ps4uYwPjAb+2ksDiz8jnfbIbtSgX/1YRuRvgTu8TqVYxuWmwBzFHU Nbq2K66V3Rf+pdMXPpfnKv+ctrZXQm6KEzl70lPfpuhZFgrU2NyeHeHSbQQ47t3TslG2 tIEQvP1cDkshcagKYNzS+8Azcd20/BPLIpp4NlftZn7EaApe37kC6WMvrfpAT0FsKOBK HLg9pxTGCLOdBnB+gBvnoUkfeyZibEbjFt2uviEyf2M0mfreZj0ymqLl9PYrLXAHCNEM TP9fz0nEnYJjPBigSvJJk50qYcwVHmmJaWjgghPnuNUy/gbIyVq3I7EKCLzOaljQwPBb VMiw== X-Gm-Message-State: AKGB3mJm4LIDfLKk7/KApuwHR7+9pMwOjOxRdHfA9z3ha9ZssDRDYh+/ Nkfi3rXzLqIJPxLnqVjtzu0= X-Google-Smtp-Source: ACJfBosfH8q1ishvgVlMf9t3yIctmPls2TVu0v0zScTqvPytnq9aboYJ/BEbjOTGwmAN9AznTAMJPg== X-Received: by 10.99.183.67 with SMTP id w3mr21112926pgt.329.1514647779195; Sat, 30 Dec 2017 07:29:39 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id f79sm81933715pfd.45.2017.12.30.07.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Dec 2017 07:29:38 -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 1/9] scsi: qla4xxx: Use zeroing allocator rather than allocator/memset Date: Sat, 30 Dec 2017 20:58:24 +0530 Message-Id: <1514647712-6332-2-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 Acked-by: Manish Rangankar --- drivers/scsi/qla4xxx/ql4_init.c | 5 ++--- drivers/scsi/qla4xxx/ql4_mbx.c | 21 +++++++++------------ drivers/scsi/qla4xxx/ql4_nx.c | 5 ++--- drivers/scsi/qla4xxx/ql4_os.c | 12 +++++------- 4 files changed, 18 insertions(+), 25 deletions(-) -- diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c index 5d6d158..52b1a0b 100644 --- a/drivers/scsi/qla4xxx/ql4_init.c +++ b/drivers/scsi/qla4xxx/ql4_init.c @@ -153,15 +153,14 @@ int qla4xxx_get_sys_info(struct scsi_qla_host *ha) dma_addr_t sys_info_dma; int status = QLA_ERROR; - sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info), - &sys_info_dma, GFP_KERNEL); + sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info), + &sys_info_dma, GFP_KERNEL); if (sys_info == NULL) { DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", ha->host_no, __func__)); goto exit_get_sys_info_no_free; } - memset(sys_info, 0, sizeof(*sys_info)); /* Get flash sys info */ if (qla4xxx_get_flash(ha, sys_info_dma, FLASH_OFFSET_SYS_INFO, diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c index 1da04f3..bda2e64 100644 --- a/drivers/scsi/qla4xxx/ql4_mbx.c +++ b/drivers/scsi/qla4xxx/ql4_mbx.c @@ -625,15 +625,14 @@ int qla4xxx_initialize_fw_cb(struct scsi_qla_host * ha) uint32_t mbox_sts[MBOX_REG_COUNT]; int status = QLA_ERROR; - init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, - sizeof(struct addr_ctrl_blk), - &init_fw_cb_dma, GFP_KERNEL); + init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, + sizeof(struct addr_ctrl_blk), + &init_fw_cb_dma, GFP_KERNEL); if (init_fw_cb == NULL) { DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, __func__)); goto exit_init_fw_cb_no_free; } - memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); /* Get Initialize Firmware Control Block. */ memset(&mbox_cmd, 0, sizeof(mbox_cmd)); @@ -710,9 +709,9 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha) uint32_t mbox_cmd[MBOX_REG_COUNT]; uint32_t mbox_sts[MBOX_REG_COUNT]; - init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, - sizeof(struct addr_ctrl_blk), - &init_fw_cb_dma, GFP_KERNEL); + init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, + sizeof(struct addr_ctrl_blk), + &init_fw_cb_dma, GFP_KERNEL); if (init_fw_cb == NULL) { printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, __func__); @@ -720,7 +719,6 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha) } /* Get Initialize Firmware Control Block. */ - memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) != QLA_SUCCESS) { DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n", @@ -1342,16 +1340,15 @@ int qla4xxx_about_firmware(struct scsi_qla_host *ha) uint32_t mbox_sts[MBOX_REG_COUNT]; int status = QLA_ERROR; - about_fw = dma_alloc_coherent(&ha->pdev->dev, - sizeof(struct about_fw_info), - &about_fw_dma, GFP_KERNEL); + about_fw = dma_zalloc_coherent(&ha->pdev->dev, + sizeof(struct about_fw_info), + &about_fw_dma, GFP_KERNEL); if (!about_fw) { DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Unable to alloc memory " "for about_fw\n", __func__)); return status; } - memset(about_fw, 0, sizeof(struct about_fw_info)); memset(&mbox_cmd, 0, sizeof(mbox_cmd)); memset(&mbox_sts, 0, sizeof(mbox_sts)); diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index e91abb3..968bd85 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c @@ -4050,15 +4050,14 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha) dma_addr_t sys_info_dma; int status = QLA_ERROR; - sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info), - &sys_info_dma, GFP_KERNEL); + sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info), + &sys_info_dma, GFP_KERNEL); if (sys_info == NULL) { DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", ha->host_no, __func__)); return status; } - memset(sys_info, 0, sizeof(*sys_info)); memset(&mbox_cmd, 0, sizeof(mbox_cmd)); memset(&mbox_sts, 0, sizeof(mbox_sts)); diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 2b8a8ce..82e889b 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -2689,16 +2689,15 @@ qla4xxx_iface_set_param(struct Scsi_Host *shost, void *data, uint32_t len) uint32_t rem = len; struct nlattr *attr; - init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, - sizeof(struct addr_ctrl_blk), - &init_fw_cb_dma, GFP_KERNEL); + init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, + sizeof(struct addr_ctrl_blk), + &init_fw_cb_dma, GFP_KERNEL); if (!init_fw_cb) { ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", __func__); return -ENOMEM; } - memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); memset(&mbox_cmd, 0, sizeof(mbox_cmd)); memset(&mbox_sts, 0, sizeof(mbox_sts)); @@ -4196,15 +4195,14 @@ static int qla4xxx_mem_alloc(struct scsi_qla_host *ha) sizeof(struct shadow_regs) + MEM_ALIGN_VALUE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); - ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len, - &ha->queues_dma, GFP_KERNEL); + ha->queues = dma_zalloc_coherent(&ha->pdev->dev, ha->queues_len, + &ha->queues_dma, GFP_KERNEL); if (ha->queues == NULL) { ql4_printk(KERN_WARNING, ha, "Memory Allocation failed - queues.\n"); goto mem_alloc_error_exit; } - memset(ha->queues, 0, ha->queues_len); /* * As per RISC alignment requirements -- the bus-address must be a