Commit fd84ec20 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Martin K. Petersen

scsi: snic: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: Karan Tilak Kumar <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 1dbaa379
...@@ -30,33 +30,13 @@ ...@@ -30,33 +30,13 @@
* fnic directory and statistics directory for trace buffer and * fnic directory and statistics directory for trace buffer and
* stats logging * stats logging
*/ */
void snic_debugfs_init(void)
int
snic_debugfs_init(void)
{ {
int rc = -1; snic_glob->trc_root = debugfs_create_dir("snic", NULL);
struct dentry *de = NULL;
de = debugfs_create_dir("snic", NULL);
if (!de) {
SNIC_DBG("Cannot create debugfs root\n");
return rc;
}
snic_glob->trc_root = de;
de = debugfs_create_dir("statistics", snic_glob->trc_root);
if (!de) {
SNIC_DBG("Cannot create Statistics directory\n");
return rc; snic_glob->stats_root = debugfs_create_dir("statistics",
} snic_glob->trc_root);
snic_glob->stats_root = de; }
rc = 0;
return rc;
} /* end of snic_debugfs_init */
/* /*
* snic_debugfs_term - Tear down debugfs intrastructure * snic_debugfs_term - Tear down debugfs intrastructure
...@@ -391,56 +371,23 @@ static const struct file_operations snic_reset_stats_fops = { ...@@ -391,56 +371,23 @@ static const struct file_operations snic_reset_stats_fops = {
* It will create file stats and reset_stats under statistics/host# directory * It will create file stats and reset_stats under statistics/host# directory
* to log per snic stats * to log per snic stats
*/ */
int void snic_stats_debugfs_init(struct snic *snic)
snic_stats_debugfs_init(struct snic *snic)
{ {
int rc = -1;
char name[16]; char name[16];
struct dentry *de = NULL;
snprintf(name, sizeof(name), "host%d", snic->shost->host_no); snprintf(name, sizeof(name), "host%d", snic->shost->host_no);
if (!snic_glob->stats_root) {
SNIC_DBG("snic_stats root doesn't exist\n");
return rc;
}
de = debugfs_create_dir(name, snic_glob->stats_root);
if (!de) {
SNIC_DBG("Cannot create host directory\n");
return rc;
}
snic->stats_host = de;
de = debugfs_create_file("stats",
S_IFREG|S_IRUGO,
snic->stats_host,
snic,
&snic_stats_fops);
if (!de) {
SNIC_DBG("Cannot create host's stats file\n");
return rc;
}
snic->stats_file = de;
de = debugfs_create_file("reset_stats",
S_IFREG|S_IRUGO|S_IWUSR,
snic->stats_host,
snic,
&snic_reset_stats_fops);
if (!de) { snic->stats_host = debugfs_create_dir(name, snic_glob->stats_root);
SNIC_DBG("Cannot create host's reset_stats file\n");
return rc; snic->stats_file = debugfs_create_file("stats", S_IFREG|S_IRUGO,
} snic->stats_host, snic,
snic->reset_stats_file = de; &snic_stats_fops);
rc = 0;
return rc; snic->reset_stats_file = debugfs_create_file("reset_stats",
} /* end of snic_stats_debugfs_init */ S_IFREG|S_IRUGO|S_IWUSR,
snic->stats_host, snic,
&snic_reset_stats_fops);
}
/* /*
* snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats * snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats
...@@ -517,46 +464,18 @@ static const struct file_operations snic_trc_fops = { ...@@ -517,46 +464,18 @@ static const struct file_operations snic_trc_fops = {
* snic_trc_debugfs_init : creates trace/tracing_enable files for trace * snic_trc_debugfs_init : creates trace/tracing_enable files for trace
* under debugfs * under debugfs
*/ */
int void snic_trc_debugfs_init(void)
snic_trc_debugfs_init(void)
{ {
struct dentry *de = NULL; snic_glob->trc.trc_enable = debugfs_create_bool("tracing_enable",
int ret = -1; S_IFREG | S_IRUGO | S_IWUSR,
snic_glob->trc_root,
if (!snic_glob->trc_root) { &snic_glob->trc.enable);
SNIC_ERR("Debugfs root directory for snic doesn't exist.\n");
snic_glob->trc.trc_file = debugfs_create_file("trace",
return ret; S_IFREG | S_IRUGO | S_IWUSR,
} snic_glob->trc_root, NULL,
&snic_trc_fops);
de = debugfs_create_bool("tracing_enable", }
S_IFREG | S_IRUGO | S_IWUSR,
snic_glob->trc_root,
&snic_glob->trc.enable);
if (!de) {
SNIC_ERR("Can't create trace_enable file.\n");
return ret;
}
snic_glob->trc.trc_enable = de;
de = debugfs_create_file("trace",
S_IFREG | S_IRUGO | S_IWUSR,
snic_glob->trc_root,
NULL,
&snic_trc_fops);
if (!de) {
SNIC_ERR("Cannot create trace file.\n");
return ret;
}
snic_glob->trc.trc_file = de;
ret = 0;
return ret;
} /* end of snic_trc_debugfs_init */
/* /*
* snic_trc_debugfs_term : cleans up the files created for trace under debugfs * snic_trc_debugfs_term : cleans up the files created for trace under debugfs
......
...@@ -397,12 +397,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -397,12 +397,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
#ifdef CONFIG_SCSI_SNIC_DEBUG_FS #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
/* Per snic debugfs init */ /* Per snic debugfs init */
ret = snic_stats_debugfs_init(snic); snic_stats_debugfs_init(snic);
if (ret) {
SNIC_HOST_ERR(snic->shost,
"Failed to initialize debugfs stats\n");
snic_stats_debugfs_remove(snic);
}
#endif #endif
/* Setup PCI Resources */ /* Setup PCI Resources */
...@@ -850,12 +845,7 @@ snic_global_data_init(void) ...@@ -850,12 +845,7 @@ snic_global_data_init(void)
#ifdef CONFIG_SCSI_SNIC_DEBUG_FS #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
/* Debugfs related Initialization */ /* Debugfs related Initialization */
/* Create debugfs entries for snic */ /* Create debugfs entries for snic */
ret = snic_debugfs_init(); snic_debugfs_init();
if (ret < 0) {
SNIC_ERR("Failed to create sysfs dir for tracing and stats.\n");
snic_debugfs_term();
/* continue even if it fails */
}
/* Trace related Initialization */ /* Trace related Initialization */
/* Allocate memory for trace buffer */ /* Allocate memory for trace buffer */
......
...@@ -99,7 +99,7 @@ struct snic_stats { ...@@ -99,7 +99,7 @@ struct snic_stats {
atomic64_t io_cmpl_skip; atomic64_t io_cmpl_skip;
}; };
int snic_stats_debugfs_init(struct snic *); void snic_stats_debugfs_init(struct snic *);
void snic_stats_debugfs_remove(struct snic *); void snic_stats_debugfs_remove(struct snic *);
/* Auxillary function to update active IO counter */ /* Auxillary function to update active IO counter */
......
...@@ -138,12 +138,7 @@ snic_trc_init(void) ...@@ -138,12 +138,7 @@ snic_trc_init(void)
trc->buf = (struct snic_trc_data *) tbuf; trc->buf = (struct snic_trc_data *) tbuf;
spin_lock_init(&trc->lock); spin_lock_init(&trc->lock);
ret = snic_trc_debugfs_init(); snic_trc_debugfs_init();
if (ret) {
SNIC_ERR("Failed to create Debugfs Files.\n");
goto error;
}
trc->max_idx = (tbuf_sz / SNIC_TRC_ENTRY_SZ); trc->max_idx = (tbuf_sz / SNIC_TRC_ENTRY_SZ);
trc->rd_idx = trc->wr_idx = 0; trc->rd_idx = trc->wr_idx = 0;
...@@ -152,11 +147,6 @@ snic_trc_init(void) ...@@ -152,11 +147,6 @@ snic_trc_init(void)
tbuf_sz / PAGE_SIZE); tbuf_sz / PAGE_SIZE);
ret = 0; ret = 0;
return ret;
error:
snic_trc_free();
return ret; return ret;
} /* end of snic_trc_init */ } /* end of snic_trc_init */
......
...@@ -53,12 +53,12 @@ struct snic_trc { ...@@ -53,12 +53,12 @@ struct snic_trc {
int snic_trc_init(void); int snic_trc_init(void);
void snic_trc_free(void); void snic_trc_free(void);
int snic_trc_debugfs_init(void); void snic_trc_debugfs_init(void);
void snic_trc_debugfs_term(void); void snic_trc_debugfs_term(void);
struct snic_trc_data *snic_get_trc_buf(void); struct snic_trc_data *snic_get_trc_buf(void);
int snic_get_trc_data(char *buf, int buf_sz); int snic_get_trc_data(char *buf, int buf_sz);
int snic_debugfs_init(void); void snic_debugfs_init(void);
void snic_debugfs_term(void); void snic_debugfs_term(void);
static inline void static inline void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment