[PATCH] [SCSI] fnic: Fix coccinelle warnings

2017-11-21 Thread Vasyl Gomonovych
Remove the duplicate copies of this simple function
and use an open-coded version.

drivers/scsi/fnic/fnic_debugfs.c:122:11-31: WARNING opportunity for 
simple_open, see also structure on line 223

Generated by: coccinelle/api/simple_open.cocci

Signed-off-by: Vasyl Gomonovych <gomonov...@gmail.com>
---
 drivers/scsi/fnic/fnic_debugfs.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 5e3d909cfc53..9858484dd126 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -108,24 +108,6 @@ void fnic_debugfs_terminate(void)
 }
 
 /*
- * fnic_trace_ctrl_open - Open the trace_enable file for fnic_trace
- *   Or Open fc_trace_enable file for fc_trace
- * @inode: The inode pointer.
- * @file: The file pointer to attach the trace enable/disable flag.
- *
- * Description:
- * This routine opens a debugsfs file trace_enable or fc_trace_enable.
- *
- * Returns:
- * This function returns zero if successful.
- */
-static int fnic_trace_ctrl_open(struct inode *inode, struct file *filp)
-{
-   filp->private_data = inode->i_private;
-   return 0;
-}
-
-/*
  * fnic_trace_ctrl_read -
  *  Read  trace_enable ,fc_trace_enable
  *  or fc_trace_clear debugfs file
@@ -220,7 +202,7 @@ static ssize_t fnic_trace_ctrl_write(struct file *filp,
 
 static const struct file_operations fnic_trace_ctrl_fops = {
.owner = THIS_MODULE,
-   .open = fnic_trace_ctrl_open,
+   .open = simple_open,
.read = fnic_trace_ctrl_read,
.write = fnic_trace_ctrl_write,
 };
-- 
1.9.1



[PATCH] scsi: lpfc: fix kzalloc-simple.cocci warnings

2017-10-11 Thread Vasyl Gomonovych
drivers/scsi/lpfc/lpfc_debugfs.c:5460:22-29: WARNING: kzalloc should be used 
for phba -> nvmeio_trc, instead of kmalloc/memset
drivers/scsi/lpfc/lpfc_debugfs.c:2230:20-27: WARNING: kzalloc should be used 
for phba -> nvmeio_trc, instead of kmalloc/memset

 Use kzalloc rather than kmalloc followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Signed-off-by: Vasyl Gomonovych <gomonov...@gmail.com>
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index d50c481..2bf5ad3 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -2227,7 +2227,7 @@
kfree(phba->nvmeio_trc);
 
/* Allocate new trace buffer and initialize */
-   phba->nvmeio_trc = kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
+   phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
sz), GFP_KERNEL);
if (!phba->nvmeio_trc) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -2235,8 +2235,6 @@
"nvmeio_trc buffer\n");
return -ENOMEM;
}
-   memset(phba->nvmeio_trc, 0,
-  (sizeof(struct lpfc_debugfs_nvmeio_trc) * sz));
atomic_set(>nvmeio_trc_cnt, 0);
phba->nvmeio_trc_on = 0;
phba->nvmeio_trc_output_idx = 0;
@@ -5457,7 +5455,7 @@ static int lpfc_idiag_cmd_get(const char __user *buf, 
size_t nbytes,
phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc;
 
/* Allocate trace buffer and initialize */
-   phba->nvmeio_trc = kmalloc(
+   phba->nvmeio_trc = kzalloc(
(sizeof(struct lpfc_debugfs_nvmeio_trc) *
phba->nvmeio_trc_size), GFP_KERNEL);
 
@@ -5467,9 +5465,6 @@ static int lpfc_idiag_cmd_get(const char __user *buf, 
size_t nbytes,
"nvmeio_trc buffer\n");
goto nvmeio_off;
}
-   memset(phba->nvmeio_trc, 0,
-  (sizeof(struct lpfc_debugfs_nvmeio_trc) *
-  phba->nvmeio_trc_size));
phba->nvmeio_trc_on = 1;
phba->nvmeio_trc_output_idx = 0;
phba->nvmeio_trc = NULL;
-- 
1.9.1