Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lpfc: don't use file->f_path.dentry for comparisons

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>

authored by

Al Viro and committed by
Greg Kroah-Hartman
3964d07d 4c0727e5

+50 -48
+39 -48
drivers/scsi/lpfc/lpfc_debugfs.c
··· 2375 2375 lpfc_debugfs_dif_err_read(struct file *file, char __user *buf, 2376 2376 size_t nbytes, loff_t *ppos) 2377 2377 { 2378 - struct dentry *dent = file->f_path.dentry; 2379 2378 struct lpfc_hba *phba = file->private_data; 2379 + int kind = debugfs_get_aux_num(file); 2380 2380 char cbuf[32]; 2381 2381 uint64_t tmp = 0; 2382 2382 int cnt = 0; 2383 2383 2384 - if (dent == phba->debug_writeGuard) 2384 + if (kind == writeGuard) 2385 2385 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt); 2386 - else if (dent == phba->debug_writeApp) 2386 + else if (kind == writeApp) 2387 2387 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt); 2388 - else if (dent == phba->debug_writeRef) 2388 + else if (kind == writeRef) 2389 2389 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt); 2390 - else if (dent == phba->debug_readGuard) 2390 + else if (kind == readGuard) 2391 2391 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt); 2392 - else if (dent == phba->debug_readApp) 2392 + else if (kind == readApp) 2393 2393 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt); 2394 - else if (dent == phba->debug_readRef) 2394 + else if (kind == readRef) 2395 2395 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt); 2396 - else if (dent == phba->debug_InjErrNPortID) 2396 + else if (kind == InjErrNPortID) 2397 2397 cnt = scnprintf(cbuf, 32, "0x%06x\n", 2398 2398 phba->lpfc_injerr_nportid); 2399 - else if (dent == phba->debug_InjErrWWPN) { 2399 + else if (kind == InjErrWWPN) { 2400 2400 memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name)); 2401 2401 tmp = cpu_to_be64(tmp); 2402 2402 cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp); 2403 - } else if (dent == phba->debug_InjErrLBA) { 2403 + } else if (kind == InjErrLBA) { 2404 2404 if (phba->lpfc_injerr_lba == (sector_t)(-1)) 2405 2405 cnt = scnprintf(cbuf, 32, "off\n"); 2406 2406 else ··· 2417 2417 lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, 2418 2418 size_t nbytes, loff_t *ppos) 2419 2419 { 2420 - struct dentry *dent = file->f_path.dentry; 2421 2420 struct lpfc_hba *phba = file->private_data; 2421 + int kind = debugfs_get_aux_num(file); 2422 2422 char dstbuf[33]; 2423 2423 uint64_t tmp = 0; 2424 2424 int size; ··· 2428 2428 if (copy_from_user(dstbuf, buf, size)) 2429 2429 return -EFAULT; 2430 2430 2431 - if (dent == phba->debug_InjErrLBA) { 2431 + if (kind == InjErrLBA) { 2432 2432 if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') && 2433 2433 (dstbuf[2] == 'f')) 2434 2434 tmp = (uint64_t)(-1); ··· 2437 2437 if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp))) 2438 2438 return -EINVAL; 2439 2439 2440 - if (dent == phba->debug_writeGuard) 2440 + if (kind == writeGuard) 2441 2441 phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp; 2442 - else if (dent == phba->debug_writeApp) 2442 + else if (kind == writeApp) 2443 2443 phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp; 2444 - else if (dent == phba->debug_writeRef) 2444 + else if (kind == writeRef) 2445 2445 phba->lpfc_injerr_wref_cnt = (uint32_t)tmp; 2446 - else if (dent == phba->debug_readGuard) 2446 + else if (kind == readGuard) 2447 2447 phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp; 2448 - else if (dent == phba->debug_readApp) 2448 + else if (kind == readApp) 2449 2449 phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp; 2450 - else if (dent == phba->debug_readRef) 2450 + else if (kind == readRef) 2451 2451 phba->lpfc_injerr_rref_cnt = (uint32_t)tmp; 2452 - else if (dent == phba->debug_InjErrLBA) 2452 + else if (kind == InjErrLBA) 2453 2453 phba->lpfc_injerr_lba = (sector_t)tmp; 2454 - else if (dent == phba->debug_InjErrNPortID) 2454 + else if (kind == InjErrNPortID) 2455 2455 phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID); 2456 - else if (dent == phba->debug_InjErrWWPN) { 2456 + else if (kind == InjErrWWPN) { 2457 2457 tmp = cpu_to_be64(tmp); 2458 2458 memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name)); 2459 2459 } else ··· 6160 6160 phba->debug_dumpHostSlim = NULL; 6161 6161 6162 6162 /* Setup DIF Error Injections */ 6163 - snprintf(name, sizeof(name), "InjErrLBA"); 6164 6163 phba->debug_InjErrLBA = 6165 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6164 + debugfs_create_file_aux_num("InjErrLBA", 0644, 6166 6165 phba->hba_debugfs_root, 6167 - phba, &lpfc_debugfs_op_dif_err); 6166 + phba, InjErrLBA, &lpfc_debugfs_op_dif_err); 6168 6167 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 6169 6168 6170 - snprintf(name, sizeof(name), "InjErrNPortID"); 6171 6169 phba->debug_InjErrNPortID = 6172 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6170 + debugfs_create_file_aux_num("InjErrNPortID", 0644, 6173 6171 phba->hba_debugfs_root, 6174 - phba, &lpfc_debugfs_op_dif_err); 6172 + phba, InjErrNPortID, &lpfc_debugfs_op_dif_err); 6175 6173 6176 - snprintf(name, sizeof(name), "InjErrWWPN"); 6177 6174 phba->debug_InjErrWWPN = 6178 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6175 + debugfs_create_file_aux_num("InjErrWWPN", 0644, 6179 6176 phba->hba_debugfs_root, 6180 - phba, &lpfc_debugfs_op_dif_err); 6177 + phba, InjErrWWPN, &lpfc_debugfs_op_dif_err); 6181 6178 6182 - snprintf(name, sizeof(name), "writeGuardInjErr"); 6183 6179 phba->debug_writeGuard = 6184 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6180 + debugfs_create_file_aux_num("writeGuardInjErr", 0644, 6185 6181 phba->hba_debugfs_root, 6186 - phba, &lpfc_debugfs_op_dif_err); 6182 + phba, writeGuard, &lpfc_debugfs_op_dif_err); 6187 6183 6188 - snprintf(name, sizeof(name), "writeAppInjErr"); 6189 6184 phba->debug_writeApp = 6190 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6185 + debugfs_create_file_aux_num("writeAppInjErr", 0644, 6191 6186 phba->hba_debugfs_root, 6192 - phba, &lpfc_debugfs_op_dif_err); 6187 + phba, writeApp, &lpfc_debugfs_op_dif_err); 6193 6188 6194 - snprintf(name, sizeof(name), "writeRefInjErr"); 6195 6189 phba->debug_writeRef = 6196 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6190 + debugfs_create_file_aux_num("writeRefInjErr", 0644, 6197 6191 phba->hba_debugfs_root, 6198 - phba, &lpfc_debugfs_op_dif_err); 6192 + phba, writeRef, &lpfc_debugfs_op_dif_err); 6199 6193 6200 - snprintf(name, sizeof(name), "readGuardInjErr"); 6201 6194 phba->debug_readGuard = 6202 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6195 + debugfs_create_file_aux_num("readGuardInjErr", 0644, 6203 6196 phba->hba_debugfs_root, 6204 - phba, &lpfc_debugfs_op_dif_err); 6197 + phba, readGuard, &lpfc_debugfs_op_dif_err); 6205 6198 6206 - snprintf(name, sizeof(name), "readAppInjErr"); 6207 6199 phba->debug_readApp = 6208 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6200 + debugfs_create_file_aux_num("readAppInjErr", 0644, 6209 6201 phba->hba_debugfs_root, 6210 - phba, &lpfc_debugfs_op_dif_err); 6202 + phba, readApp, &lpfc_debugfs_op_dif_err); 6211 6203 6212 - snprintf(name, sizeof(name), "readRefInjErr"); 6213 6204 phba->debug_readRef = 6214 - debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 6205 + debugfs_create_file_aux_num("readRefInjErr", 0644, 6215 6206 phba->hba_debugfs_root, 6216 - phba, &lpfc_debugfs_op_dif_err); 6207 + phba, readRef, &lpfc_debugfs_op_dif_err); 6217 6208 6218 6209 /* Setup slow ring trace */ 6219 6210 if (lpfc_debugfs_max_slow_ring_trc) {
+11
drivers/scsi/lpfc/lpfc_debugfs.h
··· 322 322 * discovery */ 323 323 #endif /* H_LPFC_DEBUG_FS */ 324 324 325 + enum { 326 + writeGuard = 1, 327 + writeApp, 328 + writeRef, 329 + readGuard, 330 + readApp, 331 + readRef, 332 + InjErrLBA, 333 + InjErrNPortID, 334 + InjErrWWPN, 335 + }; 325 336 326 337 /* 327 338 * Driver debug utility routines outside of debugfs. The debug utility