lkml.org 
[lkml]   [2018]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 3/4] drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset
Date
The kvcalloc is better than vmalloc() + memset() , So replace them.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
drivers/scsi/snic/snic_trc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c
index fc60c93..e766fa2 100644
--- a/drivers/scsi/snic/snic_trc.c
+++ b/drivers/scsi/snic/snic_trc.c
@@ -125,8 +125,8 @@ struct snic_trc_data *
void *tbuf = NULL;
int tbuf_sz = 0, ret;

- tbuf_sz = (snic_trace_max_pages * PAGE_SIZE);
- tbuf = vmalloc(tbuf_sz);
+ tbuf_sz = snic_trace_max_pages * PAGE_SIZE;
+ tbuf = kvcalloc(snic_trace_max_pages, PAGE_SIZE, GFP_KERNEL);
if (!tbuf) {
SNIC_ERR("Failed to Allocate Trace Buffer Size. %d\n", tbuf_sz);
SNIC_ERR("Trace Facility not enabled.\n");
@@ -135,7 +135,6 @@ struct snic_trc_data *
return ret;
}

- memset(tbuf, 0, tbuf_sz);
trc->buf = (struct snic_trc_data *) tbuf;
spin_lock_init(&trc->lock);

@@ -173,7 +172,7 @@ struct snic_trc_data *
snic_trc_debugfs_term();

if (trc->buf) {
- vfree(trc->buf);
+ kvfree(trc->buf);
trc->buf = NULL;
}

--
1.7.12.4
\
 
 \ /
  Last update: 2018-08-02 13:41    [W:0.045 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site