From patchwork Sat Dec 30 15:28:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10137791 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 D2B7F60233 for ; Sat, 30 Dec 2017 15:31:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6881287A1 for ; Sat, 30 Dec 2017 15:31:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB411287A3; Sat, 30 Dec 2017 15:31:18 +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 704C8287A1 for ; Sat, 30 Dec 2017 15:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751311AbdL3PaO (ORCPT ); Sat, 30 Dec 2017 10:30:14 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45431 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751294AbdL3PaL (ORCPT ); Sat, 30 Dec 2017 10:30:11 -0500 Received: by mail-pf0-f195.google.com with SMTP id u19so23151307pfa.12; Sat, 30 Dec 2017 07:30:11 -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=YKc4z6wyuGs2/sr7FM5lhiAWvMNUB6FPnVrzaWqHHiM=; b=c9L0GtNgXrGQSGPnsNZi1bNXE1U5h0Yj0g5Ybi6cdZvAF7FdrOXzwr52z4sFBeLKZx 3yHoNFExYn6zkuXfDYeVdDMHpPUfibOjAYz9kbNnq2jsvHSYV6lZt6yw70aWa9gpaqJo zOzxPFQAiPSsuq6tXm1upN3MJ/a3g4gLscKXvRfkXs+xDh3iXOhaeolyOyP17xkgKPdu zUN7mY9N23nz+bQwAQXnt6R9D2L0qjXont+ZCoizrqp07ymzJqthHPQva0FqHDeTfJ/3 HmN7IzAYLgGcUEDSIcBAnOcZQHC/1kDym3bq8OlybKe66CHTCZj9Vy4w38rO35TsKdFt WjAg== 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=YKc4z6wyuGs2/sr7FM5lhiAWvMNUB6FPnVrzaWqHHiM=; b=LfhiCp46+0WPTcAYKax+5ceA0XYwDZsgcLpi3HiB1pg/vpDDqjarXtaOeW0DfZR20B E9ozTX7/zQgGmJ7ggdImC5mwczweJhqxn5bTDiuQJulkl5vluuxa14DqJYoeZl2S6EdX 5E9urq05A0AIFU+qhsHzym39cY73PcK7lTLvvppchm8hC1AD0K9swke62B8G77vzyNmS kjEZC9A2qnUdXb7aiH2Zp0PJZiXlx5SF+V642Ug0jfh5GHuvlUpBxna6h1rJ3oPWSUDa Ek4Fk3IS41mVp7pyPurO55h7qLF23nUvN+EzbFCE87R/Ycp6Xm/AlQps8K98myK8GVDl BQWw== X-Gm-Message-State: AKGB3mKr0pvFdSrcr92A0PlKgkok/OmIgBiEOAnuUsGOU3FS43mCl366 4BicsFau3mbwB6BUQIcoLtQ= X-Google-Smtp-Source: ACJfBotYHCZdzpJvcJDj1hDsh9M5wSLMM3SWpcdw0PiRc4CAwvS0gZgv8eSi9zx1fa3UOGdfqugiUw== X-Received: by 10.99.168.10 with SMTP id o10mr15440725pgf.153.1514647810919; Sat, 30 Dec 2017 07:30:10 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id f79sm81933715pfd.45.2017.12.30.07.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Dec 2017 07:30:09 -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 5/9] scsi: fnic: Use zeroing allocator rather than allocator/memset Date: Sat, 30 Dec 2017 20:58:28 +0530 Message-Id: <1514647712-6332-6-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 vzalloc instead of vmalloc 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/fnic/fnic_debugfs.c | 10 ++-------- drivers/scsi/fnic/fnic_trace.c | 9 ++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c index 9858484..ec249bd 100644 --- a/drivers/scsi/fnic/fnic_debugfs.c +++ b/drivers/scsi/fnic/fnic_debugfs.c @@ -233,24 +233,18 @@ static int fnic_trace_debugfs_open(struct inode *inode, return -ENOMEM; if (*rdata_ptr == fc_trc_flag->fnic_trace) { - fnic_dbg_prt->buffer = vmalloc(3 * - (trace_max_pages * PAGE_SIZE)); + fnic_dbg_prt->buffer = vzalloc(3 * + (trace_max_pages * PAGE_SIZE)); if (!fnic_dbg_prt->buffer) { kfree(fnic_dbg_prt); return -ENOMEM; } - memset((void *)fnic_dbg_prt->buffer, 0, - 3 * (trace_max_pages * PAGE_SIZE)); fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt); } else { - fnic_dbg_prt->buffer = - vmalloc(3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); + fnic_dbg_prt->buffer = + vzalloc(3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); if (!fnic_dbg_prt->buffer) { kfree(fnic_dbg_prt); return -ENOMEM; } - memset((void *)fnic_dbg_prt->buffer, 0, - 3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); fnic_dbg_prt->buffer_len = fnic_fc_trace_get_data(fnic_dbg_prt, *rdata_ptr); } diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index 4826f59..e63285e 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c @@ -468,14 +468,13 @@ int fnic_trace_buf_init(void) fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/ FNIC_ENTRY_SIZE_BYTES; - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE)); + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages + * PAGE_SIZE)); if (!fnic_trace_buf_p) { printk(KERN_ERR PFX "Failed to allocate memory " "for fnic_trace_buf_p\n"); err = -ENOMEM; goto err_fnic_trace_buf_init; } - memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE)); fnic_trace_entries.page_offset = vmalloc(fnic_max_trace_entries * sizeof(unsigned long)); @@ -555,8 +554,7 @@ int fnic_fc_trace_init(void) fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/ FC_TRC_SIZE_BYTES; - fnic_fc_ctlr_trace_buf_p = (unsigned long)vmalloc( - fnic_fc_trace_max_pages * PAGE_SIZE); + fnic_fc_ctlr_trace_buf_p = (unsigned long)vzalloc( + fnic_fc_trace_max_pages * PAGE_SIZE); if (!fnic_fc_ctlr_trace_buf_p) { pr_err("fnic: Failed to allocate memory for " "FC Control Trace Buf\n"); @@ -564,9 +562,6 @@ int fnic_fc_trace_init(void) goto err_fnic_fc_ctlr_trace_buf_init; } - memset((void *)fnic_fc_ctlr_trace_buf_p, 0, - fnic_fc_trace_max_pages * PAGE_SIZE); - /* Allocate memory for page offset */ fc_trace_entries.page_offset = vmalloc(fc_trace_max_entries * sizeof(unsigned long));