]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lpfc: don't use file->f_path.dentry for comparisons
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 8 Jul 2025 02:57:34 +0000 (03:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2025 11:31:09 +0000 (13:31 +0200)
If you want a home-grown switch, at least use enum for selector...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250708025734.GT1880847@ZenIV
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/lpfc/lpfc_debugfs.h

index 3fd1aa5cc78cc8e252ced71f362890d983e4785d..42d138ec11b46b7da7df3d3efa1a3835ebbdf63e 100644 (file)
@@ -2375,32 +2375,32 @@ static ssize_t
 lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
        size_t nbytes, loff_t *ppos)
 {
-       struct dentry *dent = file->f_path.dentry;
        struct lpfc_hba *phba = file->private_data;
+       int kind = debugfs_get_aux_num(file);
        char cbuf[32];
        uint64_t tmp = 0;
        int cnt = 0;
 
-       if (dent == phba->debug_writeGuard)
+       if (kind == writeGuard)
                cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
-       else if (dent == phba->debug_writeApp)
+       else if (kind == writeApp)
                cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
-       else if (dent == phba->debug_writeRef)
+       else if (kind == writeRef)
                cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
-       else if (dent == phba->debug_readGuard)
+       else if (kind == readGuard)
                cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
-       else if (dent == phba->debug_readApp)
+       else if (kind == readApp)
                cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
-       else if (dent == phba->debug_readRef)
+       else if (kind == readRef)
                cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
-       else if (dent == phba->debug_InjErrNPortID)
+       else if (kind == InjErrNPortID)
                cnt = scnprintf(cbuf, 32, "0x%06x\n",
                                phba->lpfc_injerr_nportid);
-       else if (dent == phba->debug_InjErrWWPN) {
+       else if (kind == InjErrWWPN) {
                memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
                tmp = cpu_to_be64(tmp);
                cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp);
-       } else if (dent == phba->debug_InjErrLBA) {
+       } else if (kind == InjErrLBA) {
                if (phba->lpfc_injerr_lba == (sector_t)(-1))
                        cnt = scnprintf(cbuf, 32, "off\n");
                else
@@ -2417,8 +2417,8 @@ static ssize_t
 lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
        size_t nbytes, loff_t *ppos)
 {
-       struct dentry *dent = file->f_path.dentry;
        struct lpfc_hba *phba = file->private_data;
+       int kind = debugfs_get_aux_num(file);
        char dstbuf[33];
        uint64_t tmp = 0;
        int size;
@@ -2428,7 +2428,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
        if (copy_from_user(dstbuf, buf, size))
                return -EFAULT;
 
-       if (dent == phba->debug_InjErrLBA) {
+       if (kind == InjErrLBA) {
                if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') &&
                    (dstbuf[2] == 'f'))
                        tmp = (uint64_t)(-1);
@@ -2437,23 +2437,23 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
        if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
                return -EINVAL;
 
-       if (dent == phba->debug_writeGuard)
+       if (kind == writeGuard)
                phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
-       else if (dent == phba->debug_writeApp)
+       else if (kind == writeApp)
                phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp;
-       else if (dent == phba->debug_writeRef)
+       else if (kind == writeRef)
                phba->lpfc_injerr_wref_cnt = (uint32_t)tmp;
-       else if (dent == phba->debug_readGuard)
+       else if (kind == readGuard)
                phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp;
-       else if (dent == phba->debug_readApp)
+       else if (kind == readApp)
                phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp;
-       else if (dent == phba->debug_readRef)
+       else if (kind == readRef)
                phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
-       else if (dent == phba->debug_InjErrLBA)
+       else if (kind == InjErrLBA)
                phba->lpfc_injerr_lba = (sector_t)tmp;
-       else if (dent == phba->debug_InjErrNPortID)
+       else if (kind == InjErrNPortID)
                phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID);
-       else if (dent == phba->debug_InjErrWWPN) {
+       else if (kind == InjErrWWPN) {
                tmp = cpu_to_be64(tmp);
                memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name));
        } else
@@ -6160,60 +6160,51 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
                        phba->debug_dumpHostSlim = NULL;
 
                /* Setup DIF Error Injections */
-               snprintf(name, sizeof(name), "InjErrLBA");
                phba->debug_InjErrLBA =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("InjErrLBA", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, InjErrLBA, &lpfc_debugfs_op_dif_err);
                phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
 
-               snprintf(name, sizeof(name), "InjErrNPortID");
                phba->debug_InjErrNPortID =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("InjErrNPortID", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, InjErrNPortID, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "InjErrWWPN");
                phba->debug_InjErrWWPN =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("InjErrWWPN", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, InjErrWWPN, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "writeGuardInjErr");
                phba->debug_writeGuard =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("writeGuardInjErr", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, writeGuard, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "writeAppInjErr");
                phba->debug_writeApp =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("writeAppInjErr", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, writeApp, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "writeRefInjErr");
                phba->debug_writeRef =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("writeRefInjErr", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, writeRef, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "readGuardInjErr");
                phba->debug_readGuard =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("readGuardInjErr", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, readGuard, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "readAppInjErr");
                phba->debug_readApp =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("readAppInjErr", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, readApp, &lpfc_debugfs_op_dif_err);
 
-               snprintf(name, sizeof(name), "readRefInjErr");
                phba->debug_readRef =
-                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
+                       debugfs_create_file_aux_num("readRefInjErr", 0644,
                        phba->hba_debugfs_root,
-                       phba, &lpfc_debugfs_op_dif_err);
+                       phba, readRef, &lpfc_debugfs_op_dif_err);
 
                /* Setup slow ring trace */
                if (lpfc_debugfs_max_slow_ring_trc) {
index 8d2e8d05bbc05fb85ac7235fa7c0f47131d4a771..f319f3af04009f62a1374fb6901c3f2e884d96e3 100644 (file)
@@ -322,6 +322,17 @@ enum {
                                                 * discovery */
 #endif /* H_LPFC_DEBUG_FS */
 
+enum {
+       writeGuard = 1,
+       writeApp,
+       writeRef,
+       readGuard,
+       readApp,
+       readRef,
+       InjErrLBA,
+       InjErrNPortID,
+       InjErrWWPN,
+};
 
 /*
  * Driver debug utility routines outside of debugfs. The debug utility