From patchwork Sat Dec 30 15:28:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10137797 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 5DA2B60233 for ; Sat, 30 Dec 2017 15:31:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F6CA287A1 for ; Sat, 30 Dec 2017 15:31:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43E90287A3; Sat, 30 Dec 2017 15:31:46 +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 CD304287A1 for ; Sat, 30 Dec 2017 15:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751228AbdL3P3r (ORCPT ); Sat, 30 Dec 2017 10:29:47 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:45410 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbdL3P3p (ORCPT ); Sat, 30 Dec 2017 10:29:45 -0500 Received: by mail-pf0-f193.google.com with SMTP id u19so23151045pfa.12; Sat, 30 Dec 2017 07:29:44 -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=O5R1KEcIHEnfe7FRwqqOD7TToc6EWgt1iD7JzseYyKM=; b=vS7xiVO/wSfle7GYuD04NACOXBOmKSyynx6Pao0sRGfPqfuQOryvHSCVW95YZzQ45s BM0Vj9J6TbSQYQlRY/Lmu2LwFy9IaPaKAlxjTX/slWOL9FE8h3eq1WWVLEOXo2Taj/HS EYU2EQSx4IsPi/LJ7QWHKMyS6aCpEHRJ3JkaAoJsS4HNGqnEW2f4XCIN59XvXnf1Vp48 dh5UDQK0RDXPJl9r7EUWQLUOTTqK6qG1GD3kw1mOCv7kYTZDR4yc4JhfvX8SF5b2naMu W3DiVAAJ3rXR4U4Ww4mv5K2m3Rl7u/D5trRzVgxWZGM8Fg8OcLhJ0BVQP/4xkuYvAI3l CWOQ== 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=O5R1KEcIHEnfe7FRwqqOD7TToc6EWgt1iD7JzseYyKM=; b=h3vilb5xFvmoOOd0wHug6d3Xfpbq/94KaQuxjRqhdzUVv1XvOexflkNt8KODEz/MWr X6EDXQhjoySA5I5XtA/BJnHty8TpfGK9ENxwceJWWYJ+jlT7d3SFWRPyd64ayOQSPFf4 PMbAEkzupVZPic5Bm+CPZ1+6cS+VB/1aYUMogqJZ330wk8U6zcYcVW5WvqS/ZOs+rpnX w3jpZUuncTePfNknHjqxYKXhMtPwu42bxuo/u2QliOhRlru9v1HKLfBYSPF/RqLm6bqb Es20i7+NZrRt3GjbGJ/4gb2MkvnAOqAht7Y8xtTJPzWcjYVxSnp0DqJnH8ygjcDDspK3 crBA== X-Gm-Message-State: AKGB3mK71DW0H3Cazigr2HaE87cGXoXdb+x0RBkEWLhCNk8RtOBLY1Yb 55MuwNWIG7eN8MBY/Q1/82o= X-Google-Smtp-Source: ACJfBovoLzSmhWBdhlBkp0I2n6taBIqMmH5HbffJx18nFW/JZRzctleWA91byxahdtAeJAHzhVqKMw== X-Received: by 10.99.96.3 with SMTP id u3mr33569320pgb.121.1514647784266; Sat, 30 Dec 2017 07:29:44 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id f79sm81933715pfd.45.2017.12.30.07.29.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Dec 2017 07:29:43 -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 2/9] scsi: qla2xxx: Use zeroing allocator rather than allocator/memset Date: Sat, 30 Dec 2017 20:58:25 +0530 Message-Id: <1514647712-6332-3-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 and vzalloc instead of dma_alloc_coherent and vmalloc respectively, 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: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_attr.c | 5 ++--- drivers/scsi/qla2xxx/qla_bsg.c | 9 +++------ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 5 +---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 9ce28c4..f46b015 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -1843,14 +1843,13 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost) if (qla2x00_reset_active(vha)) goto done; - stats = dma_alloc_coherent(&ha->pdev->dev, - sizeof(*stats), &stats_dma, GFP_KERNEL); + stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats), + &stats_dma, GFP_KERNEL); if (!stats) { ql_log(ql_log_warn, vha, 0x707d, "Failed to allocate memory for stats.\n"); goto done; } - memset(stats, 0, sizeof(*stats)); rval = QLA_FUNCTION_FAILED; if (IS_FWI2_CAPABLE(ha)) { diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index e3ac707..e2d5d3c 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1435,7 +1435,7 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, ha->optrom_state = QLA_SREADING; } - ha->optrom_buffer = vmalloc(ha->optrom_region_size); + ha->optrom_buffer = vzalloc(ha->optrom_region_size); if (!ha->optrom_buffer) { ql_log(ql_log_warn, vha, 0x7059, "Read: Unable to allocate memory for optrom retrieval " @@ -1445,7 +1445,6 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, return -ENOMEM; } - memset(ha->optrom_buffer, 0, ha->optrom_region_size); return 0; } @@ -2314,16 +2313,14 @@ qla2x00_get_priv_stats(struct bsg_job *bsg_job) if (!IS_FWI2_CAPABLE(ha)) return -EPERM; - stats = dma_alloc_coherent(&ha->pdev->dev, - sizeof(*stats), &stats_dma, GFP_KERNEL); + stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats), + &stats_dma, GFP_KERNEL); if (!stats) { ql_log(ql_log_warn, vha, 0x70e2, "Failed to allocate memory for stats.\n"); return -ENOMEM; } - memset(stats, 0, sizeof(*stats)); - rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, options); if (rval == QLA_SUCCESS) { diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 3f82ea1..aadfeaa 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1635,16 +1635,13 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport) return rc; } - lport->lport_loopid_map = vmalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * - 65536); + lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); if (!lport->lport_loopid_map) { pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n", sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); btree_destroy32(&lport->lport_fcport_map); return -ENOMEM; } - memset(lport->lport_loopid_map, 0, sizeof(struct tcm_qla2xxx_fc_loopid) - * 65536); pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n", sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); return 0;