SCSI: cleanup debugfs usage
Subsystems (8)
cover SCSI: cleanup debugfs usage
When calling debugfs code, there is no need to ever check the return value of the call, as no logic should ever change if a call works properly or not. Fix up a bunch of x86-specific code to not care about the results of debugfs.
Greg Kroah-Hartman (7):
scsi: bfa: no need to check return value of debugfs_create functions
scsi: csiostor: no need to check return value of debugfs_create
functions
scsi: fnic: no need to check return value of debugfs_create functions
scsi: snic: no need to check return value of debugfs_create functions
scsi: lpfc: no need to check return value of debugfs_create functions
scsi: qlogic: no need to check return value of debugfs_create
functions
scsi: qla2xxx: no need to check return value of debugfs_create
functions
drivers/scsi/bfa/bfad_debugfs.c | 17 --- drivers/scsi/csiostor/csio_init.c | 6 +- drivers/scsi/fnic/fnic_debugfs.c | 88 +--------------- drivers/scsi/fnic/fnic_main.c | 7 +- drivers/scsi/fnic/fnic_stats.h | 2 +- drivers/scsi/fnic/fnic_trace.c | 17 +-- drivers/scsi/fnic/fnic_trace.h | 4 +- drivers/scsi/lpfc/lpfc_debugfs.c | 170 ------------------------------ drivers/scsi/qedf/qedf_debugfs.c | 18 +--- drivers/scsi/qedi/qedi_debugfs.c | 17 +-- drivers/scsi/qla2xxx/qla_dfs.c | 43 +------- drivers/scsi/snic/snic_debugfs.c | 133 +++++------------------ drivers/scsi/snic/snic_main.c | 14 +-- drivers/scsi/snic/snic_stats.h | 2 +- drivers/scsi/snic/snic_trc.c | 12 +-- drivers/scsi/snic/snic_trc.h | 4 +- 16 files changed, 48 insertions(+), 506 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/7 scsi: bfa: 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.
--- drivers/scsi/bfa/bfad_debugfs.c | 17 ----------------- 1 file changed, 17 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +0 -17
@@ -460,11 +460,6 @@ bfad_debugfs_init(struct bfad_port_s *port)if (!bfa_debugfs_root) { bfa_debugfs_root =debugfs_create_dir ("bfa" ,NULL );atomic_set (&bfa_debugfs_port_count,0 ); -if (!bfa_debugfs_root) { -printk (KERN_WARNING -"BFA debugfs root dir creation failed\n" ); - goto err; - } }/* Setup the pci_dev debugfs directory for the port */
@@ -472,12 +467,6 @@ bfad_debugfs_init(struct bfad_port_s *port)if (!port->port_debugfs_root) { port->port_debugfs_root =debugfs_create_dir (name, bfa_debugfs_root); -if (!port->port_debugfs_root) { -printk (KERN_WARNING -"bfa %s: debugfs root creation failed\n" , - bfad->pci_name); - goto err; - }atomic_inc (&bfa_debugfs_port_count);
@@ -489,12 +478,6 @@ bfad_debugfs_init(struct bfad_port_s *port) port->port_debugfs_root, port, file->fops); -if (!bfad->bfad_dentry_files[i]) { -printk (KERN_WARNING -"bfa %s: debugfs %s creation failed\n" , - bfad->pci_name, file->name); - goto err; - } } }
Signature · 1 line
2.20.1
PATCH 2/7 scsi: csiostor: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/scsi/csiostor/csio_init.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/scsi/csiostor/csio_init.c +1 -5
@@ -167,14 +167,10 @@ csio_dfs_destroy(struct csio_hw *hw)* csio_dfs_init - Debug filesystem initialization for the module. * */ -static int +static void csio_dfs_init (void ) { csio_debugfs_root =debugfs_create_dir (KBUILD_MODNAME ,NULL ); -if (!csio_debugfs_root) -pr_warn ("Could not create debugfs entry, continuing\n" ); - -return 0 ; }/*
Signature · 1 line
2.20.1
Re: [PATCH 2/7] scsi: csiostor: no need to check return value of debugfs_create functions
Looks good,
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 3/7 scsi: fnic: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/scsi/fnic/fnic_debugfs.c | 88 ++------------------------------ drivers/scsi/fnic/fnic_main.c | 7 +-- drivers/scsi/fnic/fnic_stats.h | 2 +- drivers/scsi/fnic/fnic_trace.c | 17 ++---- drivers/scsi/fnic/fnic_trace.h | 4 +- 5 files changed, 10 insertions(+), 108 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +3 -85
@@ -54,23 +54,9 @@ int fnic_debugfs_init(void) {int rc =-1 ; fnic_trace_debugfs_root =debugfs_create_dir ("fnic" ,NULL ); -if (!fnic_trace_debugfs_root) { -printk (KERN_DEBUG "Cannot create debugfs root\n" ); -return rc; - } - -if (!fnic_trace_debugfs_root) { -printk (KERN_DEBUG -"fnic root directory doesn't exist in debugfs\n" ); -return rc; - } fnic_stats_debugfs_root =debugfs_create_dir ("statistics" , fnic_trace_debugfs_root); -if (!fnic_stats_debugfs_root) { -printk (KERN_DEBUG "Cannot create Statistics directory\n" ); -return rc; - }/* Allocate memory to structure */ fc_trc_flag = (struct fc_trace_flag_type *)
@@ -356,39 +342,19 @@ static const struct file_operations fnic_trace_debugfs_fops = {* it will also create file trace_enable to control enable/disable of * trace logging into trace buffer. */ -int fnic_trace_debugfs_init (void ) +void fnic_trace_debugfs_init (void ) { -int rc =-1 ; -if (!fnic_trace_debugfs_root) { -printk (KERN_DEBUG -"FNIC Debugfs root directory doesn't exist\n" ); -return rc; - } fnic_trace_enable =debugfs_create_file ("tracing_enable" ,S_IFREG |S_IRUGO |S_IWUSR , fnic_trace_debugfs_root, &(fc_trc_flag->fnic_trace), &fnic_trace_ctrl_fops); -if (!fnic_trace_enable) { -printk (KERN_DEBUG -"Cannot create trace_enable file under debugfs\n" ); -return rc; - } - fnic_trace_debugfs_file =debugfs_create_file ("trace" ,S_IFREG |S_IRUGO |S_IWUSR , fnic_trace_debugfs_root, &(fc_trc_flag->fnic_trace), &fnic_trace_debugfs_fops); - -if (!fnic_trace_debugfs_file) { -printk (KERN_DEBUG -"Cannot create trace file under debugfs\n" ); -return rc; - } - rc =0 ; -return rc; }/*
@@ -419,37 +385,20 @@ void fnic_trace_debugfs_terminate(void)* trace logging into trace buffer. */ -int fnic_fc_trace_debugfs_init (void ) +void fnic_fc_trace_debugfs_init (void ) { -int rc =-1 ; - -if (!fnic_trace_debugfs_root) { -pr_err ("fnic:Debugfs root directory doesn't exist\n" ); -return rc; - } - fnic_fc_trace_enable =debugfs_create_file ("fc_trace_enable" ,S_IFREG |S_IRUGO |S_IWUSR , fnic_trace_debugfs_root, &(fc_trc_flag->fc_trace), &fnic_trace_ctrl_fops); -if (!fnic_fc_trace_enable) { -pr_err ("fnic: Failed create fc_trace_enable file\n" ); -return rc; - } - fnic_fc_trace_clear =debugfs_create_file ("fc_trace_clear" ,S_IFREG |S_IRUGO |S_IWUSR , fnic_trace_debugfs_root, &(fc_trc_flag->fc_clear), &fnic_trace_ctrl_fops); -if (!fnic_fc_trace_clear) { -pr_err ("fnic: Failed to create fc_trace_enable file\n" ); -return rc; - } - fnic_fc_rdata_trace_debugfs_file = debugfs_create_file("fc_trace_rdata", S_IFREG|S_IRUGO|S_IWUSR,
@@ -457,24 +406,12 @@ int fnic_fc_trace_debugfs_init(void) &(fc_trc_flag->fc_normal_file), &fnic_trace_debugfs_fops); -if (!fnic_fc_rdata_trace_debugfs_file) { -pr_err ("fnic: Failed create fc_rdata_trace file\n" ); -return rc; - } - fnic_fc_trace_debugfs_file =debugfs_create_file ("fc_trace" ,S_IFREG |S_IRUGO |S_IWUSR , fnic_trace_debugfs_root, &(fc_trc_flag->fc_row_file), &fnic_trace_debugfs_fops); - -if (!fnic_fc_trace_debugfs_file) { -pr_err ("fnic: Failed to create fc_trace file\n" ); -return rc; - } - rc =0 ; -return rc; }/*
@@ -757,45 +694,26 @@ static const struct file_operations fnic_reset_debugfs_fops = {* It will create file stats and reset_stats under statistics/host# directory * to log per fnic stats. */ -int fnic_stats_debugfs_init (struct fnic *fnic) +void fnic_stats_debugfs_init (struct fnic *fnic) { -int rc =-1 ;char name[16 ];snprintf (name,sizeof (name),"host%d" , fnic->lport->host->host_no); -if (!fnic_stats_debugfs_root) { -printk (KERN_DEBUG "fnic_stats root doesn't exist\n" ); -return rc; - } fnic->fnic_stats_debugfs_host =debugfs_create_dir (name, fnic_stats_debugfs_root); -if (!fnic->fnic_stats_debugfs_host) { -printk (KERN_DEBUG "Cannot create host directory\n" ); -return rc; - } fnic->fnic_stats_debugfs_file =debugfs_create_file ("stats" ,S_IFREG |S_IRUGO |S_IWUSR , fnic->fnic_stats_debugfs_host, fnic, &fnic_stats_debugfs_fops); -if (!fnic->fnic_stats_debugfs_file) { -printk (KERN_DEBUG "Cannot create host stats file\n" ); -return rc; - } fnic->fnic_reset_debugfs_file =debugfs_create_file ("reset_stats" ,S_IFREG |S_IRUGO |S_IWUSR , fnic->fnic_stats_debugfs_host, fnic, &fnic_reset_debugfs_fops); -if (!fnic->fnic_reset_debugfs_file) { -printk (KERN_DEBUG "Cannot create host stats file\n" ); -return rc; - } - rc =0 ; -return rc; }/*
drivers/scsi/fnic/fnic_main.c +1 -6
@@ -578,12 +578,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) host->transportt = fnic_fc_transport; - err =fnic_stats_debugfs_init (fnic); -if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"Failed to initialize debugfs for stats\n" ); -fnic_stats_debugfs_remove (fnic); - } +fnic_stats_debugfs_init (fnic);/* Setup PCI resources */ pci_set_drvdata (pdev, fnic);
drivers/scsi/fnic/fnic_stats.h +1 -1
@@ -134,6 +134,6 @@ struct stats_debug_info { };int fnic_get_stats_data (struct stats_debug_info *,struct fnic_stats *); -int fnic_stats_debugfs_init (struct fnic *); +void fnic_stats_debugfs_init (struct fnic *);void fnic_stats_debugfs_remove (struct fnic *);#endif /* _FNIC_STATS_H_ */
drivers/scsi/fnic/fnic_trace.c +3 -14
@@ -503,15 +503,10 @@ int fnic_trace_buf_init(void) fnic_trace_entries.page_offset[i] = fnic_buf_head; fnic_buf_head +=FNIC_ENTRY_SIZE_BYTES ; } - err =fnic_trace_debugfs_init (); -if (err <0 ) { -pr_err ("fnic: Failed to initialize debugfs for tracing\n" ); - goto err_fnic_trace_debugfs_init; - } +fnic_trace_debugfs_init ();pr_info ("fnic: Successfully Initialized Trace Buffer\n" );return err; -err_fnic_trace_debugfs_init: -fnic_trace_free (); + err_fnic_trace_buf_init:return err; }
@@ -596,16 +591,10 @@ int fnic_fc_trace_init(void) fc_trace_entries.page_offset[i] = fc_trace_buf_head; fc_trace_buf_head +=FC_TRC_SIZE_BYTES ; } - err =fnic_fc_trace_debugfs_init (); -if (err <0 ) { -pr_err ("fnic: Failed to initialize FC_CTLR tracing.\n" ); - goto err_fnic_fc_ctlr_trace_debugfs_init; - } +fnic_fc_trace_debugfs_init ();pr_info ("fnic: Successfully Initialized FC_CTLR Trace Buffer\n" );return err; -err_fnic_fc_ctlr_trace_debugfs_init: -fnic_fc_trace_free (); err_fnic_fc_ctlr_trace_buf_init:return err; }
drivers/scsi/fnic/fnic_trace.h +2 -2
@@ -111,7 +111,7 @@ int fnic_trace_buf_init(void);void fnic_trace_free (void );int fnic_debugfs_init (void );void fnic_debugfs_terminate (void ); -int fnic_trace_debugfs_init (void ); +void fnic_trace_debugfs_init (void );void fnic_trace_debugfs_terminate (void );/* Fnic FC CTLR Trace releated function */
@@ -123,7 +123,7 @@ int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag);void copy_and_format_trace_data (struct fc_trace_hdr *tdata,fnic_dbgfs_t *fnic_dbgfs_prt,int *len,u8 rdata_flag); -int fnic_fc_trace_debugfs_init (void ); +void fnic_fc_trace_debugfs_init (void );void fnic_fc_trace_debugfs_terminate (void );#endif
Signature · 1 line
2.20.1
RE: [PATCH 3/7] scsi: fnic: no need to check return value of debugfs_create functions
Looks good to me.
Satish Kharat
TECHNICAL LEADER.ENGINEERING
[email protected]
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Tuesday, January 22, 2019 7:09 AM
To: James Bottomley <[email protected]>; Martin Petersen <[email protected]>
Cc: [email protected]; [email protected]; Greg Kroah-Hartman <[email protected]>; Satish Kharat (satishkh) <[email protected]>; Sesidhar Baddela (sebaddel) <[email protected]>; Karan Tilak Kumar (kartilak) <[email protected]>
Subject: [PATCH 3/7] scsi: fnic: 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.
--- drivers/scsi/fnic/fnic_debugfs.c | 88 ++------------------------------ drivers/scsi/fnic/fnic_main.c | 7 +-- drivers/scsi/fnic/fnic_stats.h | 2 +- drivers/scsi/fnic/fnic_trace.c | 17 ++---- drivers/scsi/fnic/fnic_trace.h | 4 +- 5 files changed, 10 insertions(+), 108 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +0 -14
@@ -54,23 +54,9 @@ int fnic_debugfs_init(void) {int rc =-1 ; fnic_trace_debugfs_root =debugfs_create_dir ("fnic" ,NULL ); -if (!fnic_trace_debugfs_root) { -printk (KERN_DEBUG "Cannot create debugfs root\n" ); -return rc; - } - -if (!fnic_trace_debugfs_root) { -printk (KERN_DEBUG -"fnic root directory doesn't exist in debugfs\n" ); -return rc; - } fnic_stats_debugfs_root =debugfs_create_dir ("statistics" , fnic_trace_debugfs_root); -if (!fnic_stats_debugfs_root) { -printk (KERN_DEBUG "Cannot create Statistics directory\n" ); -return rc; - }/* Allocate memory to structure */ fc_trc_flag = (struct fc_trace_flag_type *) @@ -356,39 +342,19 @@ static const struct file_operations fnic_trace_debugfs_fops = { * it will also create file trace_enable to control enable/disable of
* trace logging into trace buffer.
*/
-int fnic_trace_debugfs_init(void)
+void fnic_trace_debugfs_init(void)
{
- int rc = -1;
- if (!fnic_trace_debugfs_root) {
- printk(KERN_DEBUG
- "FNIC Debugfs root directory doesn't exist\n");
- return rc;
- }
fnic_trace_enable = debugfs_create_file("tracing_enable",
S_IFREG|S_IRUGO|S_IWUSR, fnic_trace_debugfs_root, &(fc_trc_flag->fnic_trace), &fnic_trace_ctrl_fops);
- if (!fnic_trace_enable) {
- printk(KERN_DEBUG
- "Cannot create trace_enable file under debugfs\n");
- return rc;
- }
-
fnic_trace_debugfs_file = debugfs_create_file("trace",
S_IFREG|S_IRUGO|S_IWUSR, fnic_trace_debugfs_root, &(fc_trc_flag->fnic_trace), &fnic_trace_debugfs_fops);
-
- if (!fnic_trace_debugfs_file) {
- printk(KERN_DEBUG
- "Cannot create trace file under debugfs\n");
- return rc;
- }
- rc = 0;
- return rc;
}
/*
@@ -419,37 +385,20 @@ void fnic_trace_debugfs_terminate(void)
* trace logging into trace buffer.
*/
-int fnic_fc_trace_debugfs_init(void)
+void fnic_fc_trace_debugfs_init(void)
{
- int rc = -1;
-
- if (!fnic_trace_debugfs_root) {
- pr_err("fnic:Debugfs root directory doesn't exist\n");
- return rc;
- }
-
fnic_fc_trace_enable = debugfs_create_file("fc_trace_enable",
S_IFREG|S_IRUGO|S_IWUSR, fnic_trace_debugfs_root, &(fc_trc_flag->fc_trace), &fnic_trace_ctrl_fops);
- if (!fnic_fc_trace_enable) {
- pr_err("fnic: Failed create fc_trace_enable file\n");
- return rc;
- }
-
fnic_fc_trace_clear = debugfs_create_file("fc_trace_clear",
S_IFREG|S_IRUGO|S_IWUSR, fnic_trace_debugfs_root, &(fc_trc_flag->fc_clear), &fnic_trace_ctrl_fops);
- if (!fnic_fc_trace_clear) {
- pr_err("fnic: Failed to create fc_trace_enable file\n");
- return rc;
- }
-
fnic_fc_rdata_trace_debugfs_file =
debugfs_create_file("fc_trace_rdata",
S_IFREG|S_IRUGO|S_IWUSR,
@@ -457,24 +406,12 @@ int fnic_fc_trace_debugfs_init(void)
&(fc_trc_flag->fc_normal_file), &fnic_trace_debugfs_fops);
- if (!fnic_fc_rdata_trace_debugfs_file) {
- pr_err("fnic: Failed create fc_rdata_trace file\n");
- return rc;
- }
-
fnic_fc_trace_debugfs_file =
debugfs_create_file("fc_trace",
S_IFREG|S_IRUGO|S_IWUSR, fnic_trace_debugfs_root, &(fc_trc_flag->fc_row_file), &fnic_trace_debugfs_fops);
-
- if (!fnic_fc_trace_debugfs_file) {
- pr_err("fnic: Failed to create fc_trace file\n");
- return rc;
- }
- rc = 0;
- return rc;
}
/*
@@ -757,45 +694,26 @@ static const struct file_operations fnic_reset_debugfs_fops = {
* It will create file stats and reset_stats under statistics/host# directory
* to log per fnic stats.
*/
-int fnic_stats_debugfs_init(struct fnic *fnic)
+void fnic_stats_debugfs_init(struct fnic *fnic)
{
- int rc = -1;
char name[16];
snprintf(name, sizeof(name), "host%d", fnic->lport->host->host_no);
- if (!fnic_stats_debugfs_root) {
- printk(KERN_DEBUG "fnic_stats root doesn't exist\n");
- return rc;
- }
fnic->fnic_stats_debugfs_host = debugfs_create_dir(name,
fnic_stats_debugfs_root);
- if (!fnic->fnic_stats_debugfs_host) {
- printk(KERN_DEBUG "Cannot create host directory\n");
- return rc;
- }
fnic->fnic_stats_debugfs_file = debugfs_create_file("stats",
S_IFREG|S_IRUGO|S_IWUSR, fnic->fnic_stats_debugfs_host, fnic, &fnic_stats_debugfs_fops);
- if (!fnic->fnic_stats_debugfs_file) {
- printk(KERN_DEBUG "Cannot create host stats file\n");
- return rc;
- }
fnic->fnic_reset_debugfs_file = debugfs_create_file("reset_stats",
S_IFREG|S_IRUGO|S_IWUSR, fnic->fnic_stats_debugfs_host, fnic, &fnic_reset_debugfs_fops);
- if (!fnic->fnic_reset_debugfs_file) {
- printk(KERN_DEBUG "Cannot create host stats file\n");
- return rc;
- }
- rc = 0;
- return rc;
}
/*
drivers/scsi/fnic/fnic_main.c +1 -6
@@ -578,12 +578,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) host->transportt = fnic_fc_transport; - err =fnic_stats_debugfs_init (fnic); -if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"Failed to initialize debugfs for stats\n" ); -fnic_stats_debugfs_remove (fnic); - } +fnic_stats_debugfs_init (fnic);/* Setup PCI resources */ pci_set_drvdata (pdev, fnic);
drivers/scsi/fnic/fnic_stats.h +5 -15
@@ -134,6 +134,6 @@ struct stats_debug_info { }; int fnic_get_stats_data(struct stats_debug_info *, struct fnic_stats *); -int fnic_stats_debugfs_init(struct fnic *); +void fnic_stats_debugfs_init (struct fnic *);void fnic_stats_debugfs_remove (struct fnic *);#endif /* _FNIC_STATS_H_ */ diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index bf0fd2aeb92e..c08eda9ef086 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c
@@ -503,15 +503,10 @@ int fnic_trace_buf_init(void) fnic_trace_entries.page_offset[i] = fnic_buf_head; fnic_buf_head +=FNIC_ENTRY_SIZE_BYTES ; } - err =fnic_trace_debugfs_init (); -if (err <0 ) { -pr_err ("fnic: Failed to initialize debugfs for tracing\n" ); - goto err_fnic_trace_debugfs_init; - } +fnic_trace_debugfs_init ();pr_info ("fnic: Successfully Initialized Trace Buffer\n" );return err; -err_fnic_trace_debugfs_init: -fnic_trace_free (); + err_fnic_trace_buf_init:return err; }
@@ -596,16 +591,10 @@ int fnic_fc_trace_init(void) fc_trace_entries.page_offset[i] = fc_trace_buf_head; fc_trace_buf_head +=FC_TRC_SIZE_BYTES ; } - err =fnic_fc_trace_debugfs_init (); -if (err <0 ) { -pr_err ("fnic: Failed to initialize FC_CTLR tracing.\n" ); - goto err_fnic_fc_ctlr_trace_debugfs_init; - } +fnic_fc_trace_debugfs_init ();pr_info ("fnic: Successfully Initialized FC_CTLR Trace Buffer\n" );return err; -err_fnic_fc_ctlr_trace_debugfs_init: -fnic_fc_trace_free (); err_fnic_fc_ctlr_trace_buf_init:return err; }
drivers/scsi/fnic/fnic_trace.h +2 -1
@@ -111,7 +111,7 @@ int fnic_trace_buf_init(void); void fnic_trace_free(void); int fnic_debugfs_init(void); void fnic_debugfs_terminate(void); -int fnic_trace_debugfs_init(void); +void fnic_trace_debugfs_init (void );void fnic_trace_debugfs_terminate (void ); /* Fnic FC CTLR Trace releated function */ @@ -123,7 +123,7 @@ int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag); void copy_and_format_trace_data(struct fc_trace_hdr *tdata,fnic_dbgfs_t *fnic_dbgfs_prt,int *len,u8 rdata_flag); -int fnic_fc_trace_debugfs_init (void ); +void fnic_fc_trace_debugfs_init (void );
void fnic_fc_trace_debugfs_terminate(void);
#endif
--
2.20.1
PATCH 4/7 scsi: snic: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/scsi/snic/snic_debugfs.c | 133 ++++++------------------------- drivers/scsi/snic/snic_main.c | 14 +--- drivers/scsi/snic/snic_stats.h | 2 +- drivers/scsi/snic/snic_trc.c | 12 +-- drivers/scsi/snic/snic_trc.h | 4 +- 5 files changed, 32 insertions(+), 133 deletions(-)
drivers/scsi/snic/snic_debugfs.c +26 -107
@@ -30,33 +30,13 @@* fnic directory and statistics directory for trace buffer and * stats logging */ - -int -snic_debugfs_init (void ) +void snic_debugfs_init (void ) { -int rc =-1 ; -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" ); + snic_glob->trc_root =debugfs_create_dir ("snic" ,NULL ); -return rc; - } - snic_glob->stats_root = de; - - rc =0 ; - -return rc; -}/* end of snic_debugfs_init */ + snic_glob->stats_root =debugfs_create_dir ("statistics" , + snic_glob->trc_root); +}/* * snic_debugfs_term - Tear down debugfs intrastructure
@@ -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 * to log per snic stats */ -int -snic_stats_debugfs_init (struct snic *snic) +void snic_stats_debugfs_init (struct snic *snic) { -int rc =-1 ;char name[16 ]; -struct dentry *de =NULL ;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_DBG ("Cannot create host's reset_stats file\n" ); + snic->stats_host =debugfs_create_dir (name, snic_glob->stats_root); -return rc; - } - snic->reset_stats_file = de; - rc =0 ; + snic->stats_file =debugfs_create_file ("stats" ,S_IFREG |S_IRUGO , + snic->stats_host, snic, + &snic_stats_fops); -return rc; -}/* end of snic_stats_debugfs_init */ + snic->reset_stats_file =debugfs_create_file ("reset_stats" , +S_IFREG |S_IRUGO |S_IWUSR , + snic->stats_host, snic, + &snic_reset_stats_fops); +}/* * snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats
@@ -517,46 +464,18 @@ static const struct file_operations snic_trc_fops = {* snic_trc_debugfs_init : creates trace/tracing_enable files for trace * under debugfs */ -int -snic_trc_debugfs_init (void ) +void snic_trc_debugfs_init (void ) { -struct dentry *de =NULL ; -int ret =-1 ; - -if (!snic_glob->trc_root) { -SNIC_ERR ("Debugfs root directory for snic doesn't exist.\n" ); - -return ret; - } - - 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_glob->trc.trc_enable =debugfs_create_bool ("tracing_enable" , +S_IFREG |S_IRUGO |S_IWUSR , + snic_glob->trc_root, + &snic_glob->trc.enable); + + snic_glob->trc.trc_file =debugfs_create_file ("trace" , +S_IFREG |S_IRUGO |S_IWUSR , + snic_glob->trc_root,NULL , + &snic_trc_fops); +}/* * snic_trc_debugfs_term : cleans up the files created for trace under debugfs
drivers/scsi/snic/snic_main.c +2 -12
@@ -397,12 +397,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));#ifdef CONFIG_SCSI_SNIC_DEBUG_FS /* Per snic debugfs init */ - ret =snic_stats_debugfs_init (snic); -if (ret) { -SNIC_HOST_ERR (snic->shost, -"Failed to initialize debugfs stats\n" ); -snic_stats_debugfs_remove (snic); - } +snic_stats_debugfs_init (snic);#endif /* Setup PCI Resources */
@@ -850,12 +845,7 @@ snic_global_data_init(void)#ifdef CONFIG_SCSI_SNIC_DEBUG_FS /* Debugfs related Initialization */ /* Create debugfs entries for snic */ - ret =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 */ - } +snic_debugfs_init ();/* Trace related Initialization */ /* Allocate memory for trace buffer */
drivers/scsi/snic/snic_stats.h +1 -1
@@ -99,7 +99,7 @@ struct snic_stats {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 *);/* Auxillary function to update active IO counter */
drivers/scsi/snic/snic_trc.c +1 -11
@@ -138,12 +138,7 @@ snic_trc_init(void) trc->buf = (struct snic_trc_data *) tbuf;spin_lock_init (&trc->lock); - ret =snic_trc_debugfs_init (); -if (ret) { -SNIC_ERR ("Failed to create Debugfs Files.\n" ); - - goto error; - } +snic_trc_debugfs_init (); trc->max_idx = (tbuf_sz /SNIC_TRC_ENTRY_SZ ); trc->rd_idx = trc->wr_idx =0 ;
@@ -152,11 +147,6 @@ snic_trc_init(void) tbuf_sz / PAGE_SIZE); ret =0 ; -return ret; - -error: -snic_trc_free (); -return ret; }/* end of snic_trc_init */
drivers/scsi/snic/snic_trc.h +2 -2
@@ -53,12 +53,12 @@ struct snic_trc {int snic_trc_init (void );void snic_trc_free (void ); -int snic_trc_debugfs_init (void ); +void snic_trc_debugfs_init (void );void snic_trc_debugfs_term (void );struct snic_trc_data *snic_get_trc_buf (void );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 ); static inline void
Signature · 1 line
2.20.1
PATCH 5/7 scsi: lpfc: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 170 ------------------------------- 1 file changed, 170 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +0 -170
@@ -5280,11 +5280,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)if (!lpfc_debugfs_root) { lpfc_debugfs_root =debugfs_create_dir ("lpfc" ,NULL );atomic_set (&lpfc_debugfs_hba_count,0 ); -if (!lpfc_debugfs_root) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0408 Cannot create debugfs root\n" ); - goto debug_failed; - } }if (!lpfc_debugfs_start_time) lpfc_debugfs_start_time = jiffies;
@@ -5295,11 +5290,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) pport_setup = true; phba->hba_debugfs_root =debugfs_create_dir (name, lpfc_debugfs_root); -if (!phba->hba_debugfs_root) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0412 Cannot create debugfs hba\n" ); - goto debug_failed; - }atomic_inc (&lpfc_debugfs_hba_count);atomic_set (&phba->debugfs_vport_count,0 );
@@ -5309,11 +5299,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_hbqinfo); -if (!phba->debug_hbqinfo) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0411 Cannot create debugfs hbqinfo\n" ); - goto debug_failed; - }/* Setup dumpHBASlim */ if (phba->sli_rev <LPFC_SLI_REV4 ) {
@@ -5323,12 +5308,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dumpHBASlim); -if (!phba->debug_dumpHBASlim) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0413 Cannot create debugfs " -"dumpHBASlim\n" ); - goto debug_failed; - } }else phba->debug_dumpHBASlim =NULL ;
@@ -5340,12 +5319,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dumpHostSlim); -if (!phba->debug_dumpHostSlim) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0414 Cannot create debugfs " -"dumpHostSlim\n" ); - goto debug_failed; - } }else phba->debug_dumpHostSlim =NULL ;
@@ -5355,11 +5328,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dumpData); -if (!phba->debug_dumpData) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0800 Cannot create debugfs dumpData\n" ); - goto debug_failed; - }/* Setup dumpDif */ snprintf (name,sizeof (name),"dumpDif" );
@@ -5367,11 +5335,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dumpDif); -if (!phba->debug_dumpDif) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0801 Cannot create debugfs dumpDif\n" ); - goto debug_failed; - }/* Setup DIF Error Injections */ snprintf (name,sizeof (name),"InjErrLBA" );
@@ -5379,11 +5342,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_InjErrLBA) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0807 Cannot create debugfs InjErrLBA\n" ); - goto debug_failed; - } phba->lpfc_injerr_lba =LPFC_INJERR_LBA_OFF ;snprintf (name,sizeof (name),"InjErrNPortID" );
@@ -5391,88 +5349,48 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_InjErrNPortID) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0809 Cannot create debugfs InjErrNPortID\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"InjErrWWPN" ); phba->debug_InjErrWWPN =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_InjErrWWPN) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0810 Cannot create debugfs InjErrWWPN\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"writeGuardInjErr" ); phba->debug_writeGuard =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_writeGuard) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0802 Cannot create debugfs writeGuard\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"writeAppInjErr" ); phba->debug_writeApp =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_writeApp) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0803 Cannot create debugfs writeApp\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"writeRefInjErr" ); phba->debug_writeRef =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_writeRef) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0804 Cannot create debugfs writeRef\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"readGuardInjErr" ); phba->debug_readGuard =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_readGuard) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0808 Cannot create debugfs readGuard\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"readAppInjErr" ); phba->debug_readApp =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_readApp) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0805 Cannot create debugfs readApp\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"readRefInjErr" ); phba->debug_readRef =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_dif_err); -if (!phba->debug_readRef) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0806 Cannot create debugfs readApp\n" ); - goto debug_failed; - }/* Setup slow ring trace */ if (lpfc_debugfs_max_slow_ring_trc) {
@@ -5496,12 +5414,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_slow_ring_trc); -if (!phba->debug_slow_ring_trc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0415 Cannot create debugfs " -"slow_ring_trace\n" ); - goto debug_failed; - }if (!phba->slow_ring_trc) { phba->slow_ring_trc = kmalloc( (sizeof(struct lpfc_debugfs_trc) *
@@ -5524,11 +5436,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,0644 , phba->hba_debugfs_root, phba, &lpfc_debugfs_op_nvmeio_trc); -if (!phba->debug_nvmeio_trc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0574 No create debugfs nvmeio_trc\n" ); - goto debug_failed; - }atomic_set (&phba->nvmeio_trc_cnt,0 );if (lpfc_debugfs_max_nvmeio_trc) {
@@ -5576,11 +5483,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)if (!vport->vport_debugfs_root) { vport->vport_debugfs_root =debugfs_create_dir (name, phba->hba_debugfs_root); -if (!vport->vport_debugfs_root) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0417 Can't create debugfs\n" ); - goto debug_failed; - }atomic_inc (&phba->debugfs_vport_count); }
@@ -5617,55 +5519,29 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , vport->vport_debugfs_root, vport, &lpfc_debugfs_op_disc_trc); -if (!vport->debug_disc_trc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0419 Cannot create debugfs " -"discovery_trace\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"nodelist" ); vport->debug_nodelist =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , vport->vport_debugfs_root, vport, &lpfc_debugfs_op_nodelist); -if (!vport->debug_nodelist) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2985 Can't create debugfs nodelist\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"nvmestat" ); vport->debug_nvmestat =debugfs_create_file (name,0644 , vport->vport_debugfs_root, vport, &lpfc_debugfs_op_nvmestat); -if (!vport->debug_nvmestat) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0811 Cannot create debugfs nvmestat\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"nvmektime" ); vport->debug_nvmektime =debugfs_create_file (name,0644 , vport->vport_debugfs_root, vport, &lpfc_debugfs_op_nvmektime); -if (!vport->debug_nvmektime) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0815 Cannot create debugfs nvmektime\n" ); - goto debug_failed; - }snprintf (name,sizeof (name),"cpucheck" ); vport->debug_cpucheck =debugfs_create_file (name,0644 , vport->vport_debugfs_root, vport, &lpfc_debugfs_op_cpucheck); -if (!vport->debug_cpucheck) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"0819 Cannot create debugfs cpucheck\n" ); - goto debug_failed; - }/* * The following section is for additional directories/files for the
@@ -5685,11 +5561,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)if (!phba->idiag_root) { phba->idiag_root =debugfs_create_dir (name, phba->hba_debugfs_root); -if (!phba->idiag_root) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2922 Can't create idiag debugfs\n" ); - goto debug_failed; - }/* Initialize iDiag data structure */ memset (&idiag,0 ,sizeof (idiag)); }
@@ -5700,11 +5571,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_pci_cfg =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_pciCfg); -if (!phba->idiag_pci_cfg) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2923 Can't create idiag debugfs\n" ); - goto debug_failed; - } idiag.offset.last_rd =0 ; }
@@ -5714,11 +5580,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_bar_acc =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_barAcc); -if (!phba->idiag_bar_acc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"3056 Can't create idiag debugfs\n" ); - goto debug_failed; - } idiag.offset.last_rd =0 ; }
@@ -5728,11 +5589,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_que_info =debugfs_create_file (name,S_IFREG |S_IRUGO , phba->idiag_root, phba, &lpfc_idiag_op_queInfo); -if (!phba->idiag_que_info) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2924 Can't create idiag debugfs\n" ); - goto debug_failed; - } }/* iDiag access PCI function queue */
@@ -5741,11 +5597,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_que_acc =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_queAcc); -if (!phba->idiag_que_acc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2926 Can't create idiag debugfs\n" ); - goto debug_failed; - } }/* iDiag access PCI function doorbell registers */
@@ -5754,11 +5605,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_drb_acc =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_drbAcc); -if (!phba->idiag_drb_acc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2927 Can't create idiag debugfs\n" ); - goto debug_failed; - } }/* iDiag access PCI function control registers */
@@ -5767,11 +5613,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_ctl_acc =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_ctlAcc); -if (!phba->idiag_ctl_acc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2981 Can't create idiag debugfs\n" ); - goto debug_failed; - } }/* iDiag access mbox commands */
@@ -5780,11 +5621,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) phba->idiag_mbx_acc =debugfs_create_file (name,S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_mbxAcc); -if (!phba->idiag_mbx_acc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2980 Can't create idiag debugfs\n" ); - goto debug_failed; - } }/* iDiag extents access commands */
@@ -5796,12 +5632,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)S_IFREG |S_IRUGO |S_IWUSR , phba->idiag_root, phba, &lpfc_idiag_op_extAcc); -if (!phba->idiag_ext_acc) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_INIT , -"2986 Cant create " -"idiag debugfs\n" ); - goto debug_failed; - } } }
Signature · 1 line
2.20.1
PATCH 6/7 scsi: qlogic: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/scsi/qedf/qedf_debugfs.c | 18 ++---------------- drivers/scsi/qedi/qedi_debugfs.c | 17 ++--------------- 2 files changed, 4 insertions(+), 31 deletions(-)
drivers/scsi/qedf/qedf_debugfs.c +2 -16
@@ -27,30 +27,19 @@ qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, const struct file_operations *fops) {char host_dirname[32 ]; -struct dentry *file_dentry =NULL ;QEDF_INFO (qedf,QEDF_LOG_DEBUGFS ,"Creating debugfs host node\n" );/* create pf dir */ sprintf (host_dirname,"host%u" , qedf->host_no); qedf->bdf_dentry =debugfs_create_dir (host_dirname, qedf_dbg_root); -if (!qedf->bdf_dentry) -return ;/* create debugfs files */ while (dops) {if (!(dops->name))break ; - file_dentry =debugfs_create_file (dops->name,0600 , - qedf->bdf_dentry, qedf, - fops); -if (!file_dentry) { -QEDF_INFO (qedf,QEDF_LOG_DEBUGFS , -"Debugfs entry %s creation failed\n" , - dops->name); -debugfs_remove_recursive (qedf->bdf_dentry); -return ; - } +debugfs_create_file (dops->name,0600 , qedf->bdf_dentry, qedf, + fops); dops++; fops++; }
@@ -80,9 +69,6 @@ qedf_dbg_init(char *drv_name)/* create qed dir in root of debugfs. NULL means debugfs root */ qedf_dbg_root =debugfs_create_dir (drv_name,NULL ); -if (!qedf_dbg_root) -QEDF_INFO (NULL ,QEDF_LOG_DEBUGFS ,"Init of debugfs " -"failed\n" ); }/**
drivers/scsi/qedi/qedi_debugfs.c +2 -15
@@ -23,27 +23,16 @@ qedi_dbg_host_init(struct qedi_dbg_ctx *qedi, const struct file_operations *fops) {char host_dirname[32 ]; -struct dentry *file_dentry =NULL ;sprintf (host_dirname,"host%u" , qedi->host_no); qedi->bdf_dentry =debugfs_create_dir (host_dirname, qedi_dbg_root); -if (!qedi->bdf_dentry) -return ;while (dops) {if (!(dops->name))break ; - file_dentry =debugfs_create_file (dops->name,0600 , - qedi->bdf_dentry, qedi, - fops); -if (!file_dentry) { -QEDI_INFO (qedi,QEDI_LOG_DEBUGFS , -"Debugfs entry %s creation failed\n" , - dops->name); -debugfs_remove_recursive (qedi->bdf_dentry); -return ; - } +debugfs_create_file (dops->name,0600 , qedi->bdf_dentry, qedi, + fops); dops++; fops++; }
@@ -60,8 +49,6 @@ void qedi_dbg_init(char *drv_name) { qedi_dbg_root =debugfs_create_dir (drv_name,NULL ); -if (!qedi_dbg_root) -QEDI_INFO (NULL ,QEDI_LOG_DEBUGFS ,"Init of debugfs failed\n" ); }void
Signature · 1 line
2.20.1
RE: [PATCH 6/7] scsi: qlogic: no need to check return value of debugfs_create functions
Quoted 120 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Tuesday, January 22, 2019 8:39 PM
To: James Bottomley <[email protected]>; Martin Petersen <[email protected]>
Cc: [email protected]; [email protected]; Greg Kroah- Hartman <[email protected]>; QLogic-Storage- [email protected]
Subject: [PATCH 6/7] scsi: qlogic: no need to check return value ofdebugfs_createfunctionsExternal Email
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 "James E.J. Bottomley" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/scsi/qedf/qedf_debugfs.c | 18 ++---------------- drivers/scsi/qedi/qedi_debugfs.c | 17 ++--------------- 2 files changed, 4 insertions(+), 31 deletions(-)drivers/scsi/qedf/qedf_debugfs.c +2
-13@@ -27,30 +27,19 @@ qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, const struct file_operations *fops) {char host_dirname[32 ]; -struct dentry *file_dentry =NULL ;QEDF_INFO (qedf,QEDF_LOG_DEBUGFS ,"Creating debugfs host node\n");/* create pf dir */ sprintf (host_dirname,"host%u" , qedf->host_no); qedf->bdf_dentry =debugfs_create_dir (host_dirname, qedf_dbg_root); -if (!qedf->bdf_dentry) -return ;/* create debugfs files */ while (dops) {if (!(dops->name))break ; - file_dentry =debugfs_create_file (dops->name,0600 , - qedf->bdf_dentry, qedf, - fops); -if (!file_dentry) { -QEDF_INFO (qedf,QEDF_LOG_DEBUGFS , -"Debugfs entry %s creation failed\n" , - dops->name); -debugfs_remove_recursive (qedf->bdf_dentry); -return ; - } +debugfs_create_file (dops->name,0600 , qedf->bdf_dentry, qedf, + fops); dops++; fops++;}drivers/scsi/qedf/qedf_debugfs.c +0
-3@@ -80,9 +69,6 @@ qedf_dbg_init(char *drv_name)/* create qed dir in root of debugfs. NULL means debugfs root */ qedf_dbg_root =debugfs_create_dir (drv_name,NULL ); -if (!qedf_dbg_root) -QEDF_INFO (NULL ,QEDF_LOG_DEBUGFS ,"Init of debugfs " -"failed\n" ); }/** drivers/scsi/qedi/qedi_debugfs.c +2
-16@@ -23,27 +23,16 @@ qedi_dbg_host_init(struct qedi_dbg_ctx *qedi, const struct file_operations *fops) {char host_dirname[32 ]; -struct dentry *file_dentry =NULL ;sprintf (host_dirname,"host%u" , qedi->host_no); qedi->bdf_dentry =debugfs_create_dir (host_dirname, qedi_dbg_root); -if (!qedi->bdf_dentry) -return ;while (dops) {if (!(dops->name))break ; - file_dentry =debugfs_create_file (dops->name,0600 , - qedi->bdf_dentry, qedi, - fops); -if (!file_dentry) { -QEDI_INFO (qedi,QEDI_LOG_DEBUGFS , -"Debugfs entry %s creation failed\n" , - dops->name); -debugfs_remove_recursive (qedi->bdf_dentry); -return ; - } +debugfs_create_file (dops->name,0600 , qedi->bdf_dentry, qedi, + fops); dops++; fops++; }@@ -60,8 +49,6 @@ void qedi_dbg_init(char *drv_name) { qedi_dbg_root =debugfs_create_dir (drv_name,NULL ); -if (!qedi_dbg_root) -QEDI_INFO (NULL ,QEDI_LOG_DEBUGFS ,"Init of debugfs failed\n" ); }void --
Quoted 1 line
2.20.1
Thanks
PATCH 7/7 scsi: qla2xxx: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/scsi/qla2xxx/qla_dfs.c | 43 +--------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-)
drivers/scsi/qla2xxx/qla_dfs.c +1 -42
@@ -446,11 +446,6 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha)atomic_set (&qla2x00_dfs_root_count,0 ); qla2x00_dfs_root =debugfs_create_dir (QLA2XXX_DRIVER_NAME ,NULL ); -if (!qla2x00_dfs_root) { -ql_log (ql_log_warn, vha,0x00f7 , -"Unable to create debugfs root directory.\n" ); - goto out; - } create_dir:if (ha->dfs_dir)
@@ -458,64 +453,28 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha)mutex_init (&ha->fce_mutex); ha->dfs_dir =debugfs_create_dir (vha->host_str, qla2x00_dfs_root); -if (!ha->dfs_dir) { -ql_log (ql_log_warn, vha,0x00f8 , -"Unable to create debugfs ha directory.\n" ); - goto out; - }atomic_inc (&qla2x00_dfs_root_count); create_nodes: ha->dfs_fw_resource_cnt =debugfs_create_file ("fw_resource_count" ,S_IRUSR , ha->dfs_dir, vha, &dfs_fw_resource_cnt_ops); -if (!ha->dfs_fw_resource_cnt) { -ql_log (ql_log_warn, vha,0x00fd , -"Unable to create debugFS fw_resource_count node.\n" ); - goto out; - } ha->dfs_tgt_counters =debugfs_create_file ("tgt_counters" ,S_IRUSR , ha->dfs_dir, vha, &dfs_tgt_counters_ops); -if (!ha->dfs_tgt_counters) { -ql_log (ql_log_warn, vha,0xd301 , -"Unable to create debugFS tgt_counters node.\n" ); - goto out; - } ha->tgt.dfs_tgt_port_database =debugfs_create_file ("tgt_port_database" ,S_IRUSR , ha->dfs_dir, vha, &dfs_tgt_port_database_ops); -if (!ha->tgt.dfs_tgt_port_database) { -ql_log (ql_log_warn, vha,0xd03f , -"Unable to create debugFS tgt_port_database node.\n" ); - goto out; - } ha->dfs_fce =debugfs_create_file ("fce" ,S_IRUSR , ha->dfs_dir, vha, &dfs_fce_ops); -if (!ha->dfs_fce) { -ql_log (ql_log_warn, vha,0x00f9 , -"Unable to create debugfs fce node.\n" ); - goto out; - } ha->tgt.dfs_tgt_sess =debugfs_create_file ("tgt_sess" ,S_IRUSR , ha->dfs_dir, vha, &dfs_tgt_sess_ops); -if (!ha->tgt.dfs_tgt_sess) { -ql_log (ql_log_warn, vha,0xd040 , -"Unable to create debugFS tgt_sess node.\n" ); - goto out; - } -if (IS_QLA27XX (ha) ||IS_QLA83XX (ha)) { +if (IS_QLA27XX (ha) ||IS_QLA83XX (ha)) ha->tgt.dfs_naqp =debugfs_create_file ("naqp" ,0400 , ha->dfs_dir, vha, &dfs_naqp_ops); -if (!ha->tgt.dfs_naqp) { -ql_log (ql_log_warn, vha,0xd011 , -"Unable to create debugFS naqp node.\n" ); - goto out; - } - } out:return 0 ; }
Signature · 1 line
2.20.1
Quoted 5 lines · Greg Kroah-Hartman
When calling debugfs code, there is no need to ever check the return value of the call, as no logic should ever change if a call works properly or not. Fix up a bunch of x86-specific code to not care about the results of debugfs.
Quoted 12 lines
Greg Kroah-Hartman (7):
scsi: bfa: no need to check return value ofdebugfs_createfunctions
scsi: csiostor: no need to check return value ofdebugfs_create
functions
scsi: fnic: no need to check return value ofdebugfs_createfunctions
scsi: snic: no need to check return value ofdebugfs_createfunctions
scsi: lpfc: no need to check return value ofdebugfs_createfunctions
scsi: qlogic: no need to check return value ofdebugfs_create
functions
scsi: qla2xxx: no need to check return value ofdebugfs_create
functions
JFYI, Martin has some more debugfs usage queued for 5.1 here:
https://kernel.googlesource.com/pub/scm/linux/kernel/git/mkp/scsi/+log/5.1/scsi-queue/drivers/scsi/hisi_sas
I'll send a patch to tidy-up, as above. It would not be x86 specific, but I am not sure what above is.
Thanks,
John
Quoted 18 lines
drivers/scsi/bfa/bfad_debugfs.c | 17 --- drivers/scsi/csiostor/csio_init.c | 6 +- drivers/scsi/fnic/fnic_debugfs.c | 88 +--------------- drivers/scsi/fnic/fnic_main.c | 7 +- drivers/scsi/fnic/fnic_stats.h | 2 +- drivers/scsi/fnic/fnic_trace.c | 17 +-- drivers/scsi/fnic/fnic_trace.h | 4 +- drivers/scsi/lpfc/lpfc_debugfs.c | 170 ------------------------------ drivers/scsi/qedf/qedf_debugfs.c | 18 +--- drivers/scsi/qedi/qedi_debugfs.c | 17 +-- drivers/scsi/qla2xxx/qla_dfs.c | 43 +------- drivers/scsi/snic/snic_debugfs.c | 133 +++++------------------ drivers/scsi/snic/snic_main.c | 14 +-- drivers/scsi/snic/snic_stats.h | 2 +- drivers/scsi/snic/snic_trc.c | 12 +-- drivers/scsi/snic/snic_trc.h | 4 +- 16 files changed, 48 insertions(+), 506 deletions(-)
Martin K. Petersen
AppliedGreg,
Quoted 4 lines
When calling debugfs code, there is no need to ever check the return value of the call, as no logic should ever change if a call works properly or not. Fix up a bunch of x86-specific code to not care about the results of debugfs.
Applied to 5.1/scsi-queue, thank you!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering