scsi: snic: debugfs: remove local storage of debugfs files
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 May 2021 16:16:25 +0000 (18:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 May 2021 18:46:45 +0000 (20:46 +0200)
There is no need to keep the dentry around for the debugfs trace files,
as we can just look it up when we want to remove it later on.  Simplify
the structure by removing the dentries and relying on debugfs to find
the dentry to remove when we want to.

By doing this change, we remove the last in-kernel user that was storing
the result of debugfs_create_bool(), so that api can be cleaned up.

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>
Link: https://lore.kernel.org/r/20210518161625.3696996-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/snic/snic_debugfs.c
drivers/scsi/snic/snic_trc.h

index 3aeee856d5c7b2e9e093bff9ecc1909bbc0ca27c..5e0faeba516e57b5d4fae88430208b05b892e3a6 100644 (file)
@@ -430,21 +430,19 @@ static const struct seq_operations snic_trc_sops = {
 
 DEFINE_SEQ_ATTRIBUTE(snic_trc);
 
+#define TRC_ENABLE_FILE        "tracing_enable"
+#define TRC_FILE       "trace"
 /*
  * snic_trc_debugfs_init : creates trace/tracing_enable files for trace
  * under debugfs
  */
 void snic_trc_debugfs_init(void)
 {
-       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);
+       debugfs_create_bool(TRC_ENABLE_FILE, S_IFREG | S_IRUGO | S_IWUSR,
+                           snic_glob->trc_root, &snic_glob->trc.enable);
+
+       debugfs_create_file(TRC_FILE, S_IFREG | S_IRUGO | S_IWUSR,
+                           snic_glob->trc_root, NULL, &snic_trc_fops);
 }
 
 /*
@@ -453,9 +451,6 @@ void snic_trc_debugfs_init(void)
 void
 snic_trc_debugfs_term(void)
 {
-       debugfs_remove(snic_glob->trc.trc_file);
-       snic_glob->trc.trc_file = NULL;
-
-       debugfs_remove(snic_glob->trc.trc_enable);
-       snic_glob->trc.trc_enable = NULL;
+       debugfs_remove(debugfs_lookup(TRC_FILE, snic_glob->trc_root));
+       debugfs_remove(debugfs_lookup(TRC_ENABLE_FILE, snic_glob->trc_root));
 }
index 87dcc7457d15aa21efc3f63f30cda9fab4ba70f2..ce305b4b8fa2079da91b6bd5677c67cd6b0e5a01 100644 (file)
@@ -46,9 +46,6 @@ struct snic_trc {
        u32     rd_idx;
        u32     wr_idx;
        bool    enable;                 /* Control Variable for Tracing */
-
-       struct dentry *trc_enable;      /* debugfs file object */
-       struct dentry *trc_file;
 };
 
 int snic_trc_init(void);