From nobody Wed Nov 27 19:43:38 2024 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CB4416EB42; Tue, 8 Oct 2024 09:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728381173; cv=none; b=VOJZRIz0JowQ6n2kwiaUrmF3fbicr2K+xRWLv5f8AgKTJDZ/K9KqQvleilUHTWoK1MPoGwpIZBq87XRnhbHycsdZx9ZbdQcoNgW2X6Wn/lpkgACs+BwdX036s5E+GaZEo2WN6gSIwR0LRE7hveXD3k3A5KNwqEbbbKpbDqwTrz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728381173; c=relaxed/simple; bh=5ICUhILdpfrxIIwr2tfTau2AQ1AHNhcAgTKAZF4zV9M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hJTwohEo34kcWoXGoohZxVq7kF1PpOTJaMvvgZJUN+NrSqrnb8mXg4IVAjuo85tGKZz1jWGKgIB0XM+H3GVCbIUf3VZ0lI5RgLN/Mq4JSBVNXbHmPVMuYrEi0nhRpQHtACfvd4GQTRw7iL5HWl6qZfPqHujTIG8hG8GPJPo+fc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DoPIMM05; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DoPIMM05" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1728381169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=S9QFJs3/7SCYKlhjm/bk9r+W0r0GmzkRfjIaRjfie8s=; b=DoPIMM05m20Oj8L4eAhV9ugiuMHG6PsFStZfAk9YLS2FPIFQNk8KBS4t0ec1qdKYp9aDQV Zb1QvkJ2QzJuYcQ2P+QW+TkV0k4RZoazWqd37qjRcUI85osSmsIpzyXQJ1MkzdPr2nSw6h t5CpfV5K4fNJs0juN/AFEL7/tWVJg/E= From: Thorsten Blum To: Satish Kharat , Sesidhar Baddela , Karan Tilak Kumar , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Thorsten Blum , Johannes Thumshirn , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0) Date: Tue, 8 Oct 2024 11:51:53 +0200 Message-ID: <20241008095152.1831-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Use vzalloc() instead of vmalloc() followed by memset(0) to simplify the functions fnic_trace_buf_init() and fnic_fc_trace_init(). Remove unnecessary unsigned long cast. Compile-tested only. Cc: Johannes Thumshirn Signed-off-by: Thorsten Blum --- Changes in v2: - Remove unsigned long cast as suggested by Johannes Thumshirn - Link to v1: https://lore.kernel.org/linux-kernel/20241007115840.2239-6-th= orsten.blum@linux.dev/ --- drivers/scsi/fnic/fnic_trace.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index aaa4ea02fb7c..c2413e0e4eaa 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c @@ -485,7 +485,7 @@ int fnic_trace_buf_init(void) } =20 fnic_trace_entries.page_offset =3D - vmalloc(array_size(fnic_max_trace_entries, + vzalloc(array_size(fnic_max_trace_entries, sizeof(unsigned long))); if (!fnic_trace_entries.page_offset) { printk(KERN_ERR PFX "Failed to allocate memory for" @@ -497,8 +497,6 @@ int fnic_trace_buf_init(void) err =3D -ENOMEM; goto err_fnic_trace_buf_init; } - memset((void *)fnic_trace_entries.page_offset, 0, - (fnic_max_trace_entries * sizeof(unsigned long))); fnic_trace_entries.wr_idx =3D fnic_trace_entries.rd_idx =3D 0; fnic_buf_head =3D fnic_trace_buf_p; =20 @@ -559,8 +557,7 @@ int fnic_fc_trace_init(void) fc_trace_max_entries =3D (fnic_fc_trace_max_pages * PAGE_SIZE)/ FC_TRC_SIZE_BYTES; fnic_fc_ctlr_trace_buf_p =3D - (unsigned long)vmalloc(array_size(PAGE_SIZE, - fnic_fc_trace_max_pages)); + vzalloc(array_size(PAGE_SIZE, fnic_fc_trace_max_pages)); if (!fnic_fc_ctlr_trace_buf_p) { pr_err("fnic: Failed to allocate memory for " "FC Control Trace Buf\n"); @@ -568,12 +565,9 @@ int fnic_fc_trace_init(void) goto err_fnic_fc_ctlr_trace_buf_init; } =20 - 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 =3D - vmalloc(array_size(fc_trace_max_entries, + vzalloc(array_size(fc_trace_max_entries, sizeof(unsigned long))); if (!fc_trace_entries.page_offset) { pr_err("fnic:Failed to allocate memory for page_offset\n"); @@ -585,8 +579,6 @@ int fnic_fc_trace_init(void) err =3D -ENOMEM; goto err_fnic_fc_ctlr_trace_buf_init; } - memset((void *)fc_trace_entries.page_offset, 0, - (fc_trace_max_entries * sizeof(unsigned long))); =20 fc_trace_entries.rd_idx =3D fc_trace_entries.wr_idx =3D 0; fc_trace_buf_head =3D fnic_fc_ctlr_trace_buf_p; --=20 2.46.2