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

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Greg Kroah-Hartman and committed by
Martin K. Petersen
fd84ec20 1dbaa379

+31 -132
+25 -106
drivers/scsi/snic/snic_debugfs.c
··· 30 30 * fnic directory and statistics directory for trace buffer and 31 31 * stats logging 32 32 */ 33 - 34 - int 35 - snic_debugfs_init(void) 33 + void snic_debugfs_init(void) 36 34 { 37 - int rc = -1; 38 - struct dentry *de = NULL; 35 + snic_glob->trc_root = debugfs_create_dir("snic", NULL); 39 36 40 - de = debugfs_create_dir("snic", NULL); 41 - if (!de) { 42 - SNIC_DBG("Cannot create debugfs root\n"); 43 - 44 - return rc; 45 - } 46 - snic_glob->trc_root = de; 47 - 48 - de = debugfs_create_dir("statistics", snic_glob->trc_root); 49 - if (!de) { 50 - SNIC_DBG("Cannot create Statistics directory\n"); 51 - 52 - return rc; 53 - } 54 - snic_glob->stats_root = de; 55 - 56 - rc = 0; 57 - 58 - return rc; 59 - } /* end of snic_debugfs_init */ 37 + snic_glob->stats_root = debugfs_create_dir("statistics", 38 + snic_glob->trc_root); 39 + } 60 40 61 41 /* 62 42 * snic_debugfs_term - Tear down debugfs intrastructure ··· 371 391 * It will create file stats and reset_stats under statistics/host# directory 372 392 * to log per snic stats 373 393 */ 374 - int 375 - snic_stats_debugfs_init(struct snic *snic) 394 + void snic_stats_debugfs_init(struct snic *snic) 376 395 { 377 - int rc = -1; 378 396 char name[16]; 379 - struct dentry *de = NULL; 380 397 381 398 snprintf(name, sizeof(name), "host%d", snic->shost->host_no); 382 - if (!snic_glob->stats_root) { 383 - SNIC_DBG("snic_stats root doesn't exist\n"); 384 399 385 - return rc; 386 - } 400 + snic->stats_host = debugfs_create_dir(name, snic_glob->stats_root); 387 401 388 - de = debugfs_create_dir(name, snic_glob->stats_root); 389 - if (!de) { 390 - SNIC_DBG("Cannot create host directory\n"); 402 + snic->stats_file = debugfs_create_file("stats", S_IFREG|S_IRUGO, 403 + snic->stats_host, snic, 404 + &snic_stats_fops); 391 405 392 - return rc; 393 - } 394 - snic->stats_host = de; 395 - 396 - de = debugfs_create_file("stats", 397 - S_IFREG|S_IRUGO, 398 - snic->stats_host, 399 - snic, 400 - &snic_stats_fops); 401 - if (!de) { 402 - SNIC_DBG("Cannot create host's stats file\n"); 403 - 404 - return rc; 405 - } 406 - snic->stats_file = de; 407 - 408 - de = debugfs_create_file("reset_stats", 409 - S_IFREG|S_IRUGO|S_IWUSR, 410 - snic->stats_host, 411 - snic, 412 - &snic_reset_stats_fops); 413 - 414 - if (!de) { 415 - SNIC_DBG("Cannot create host's reset_stats file\n"); 416 - 417 - return rc; 418 - } 419 - snic->reset_stats_file = de; 420 - rc = 0; 421 - 422 - return rc; 423 - } /* end of snic_stats_debugfs_init */ 406 + snic->reset_stats_file = debugfs_create_file("reset_stats", 407 + S_IFREG|S_IRUGO|S_IWUSR, 408 + snic->stats_host, snic, 409 + &snic_reset_stats_fops); 410 + } 424 411 425 412 /* 426 413 * snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats ··· 464 517 * snic_trc_debugfs_init : creates trace/tracing_enable files for trace 465 518 * under debugfs 466 519 */ 467 - int 468 - snic_trc_debugfs_init(void) 520 + void snic_trc_debugfs_init(void) 469 521 { 470 - struct dentry *de = NULL; 471 - int ret = -1; 522 + snic_glob->trc.trc_enable = debugfs_create_bool("tracing_enable", 523 + S_IFREG | S_IRUGO | S_IWUSR, 524 + snic_glob->trc_root, 525 + &snic_glob->trc.enable); 472 526 473 - if (!snic_glob->trc_root) { 474 - SNIC_ERR("Debugfs root directory for snic doesn't exist.\n"); 475 - 476 - return ret; 477 - } 478 - 479 - de = debugfs_create_bool("tracing_enable", 480 - S_IFREG | S_IRUGO | S_IWUSR, 481 - snic_glob->trc_root, 482 - &snic_glob->trc.enable); 483 - 484 - if (!de) { 485 - SNIC_ERR("Can't create trace_enable file.\n"); 486 - 487 - return ret; 488 - } 489 - snic_glob->trc.trc_enable = de; 490 - 491 - de = debugfs_create_file("trace", 492 - S_IFREG | S_IRUGO | S_IWUSR, 493 - snic_glob->trc_root, 494 - NULL, 495 - &snic_trc_fops); 496 - 497 - if (!de) { 498 - SNIC_ERR("Cannot create trace file.\n"); 499 - 500 - return ret; 501 - } 502 - snic_glob->trc.trc_file = de; 503 - ret = 0; 504 - 505 - return ret; 506 - } /* end of snic_trc_debugfs_init */ 527 + snic_glob->trc.trc_file = debugfs_create_file("trace", 528 + S_IFREG | S_IRUGO | S_IWUSR, 529 + snic_glob->trc_root, NULL, 530 + &snic_trc_fops); 531 + } 507 532 508 533 /* 509 534 * snic_trc_debugfs_term : cleans up the files created for trace under debugfs
+2 -12
drivers/scsi/snic/snic_main.c
··· 397 397 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); 398 398 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS 399 399 /* Per snic debugfs init */ 400 - ret = snic_stats_debugfs_init(snic); 401 - if (ret) { 402 - SNIC_HOST_ERR(snic->shost, 403 - "Failed to initialize debugfs stats\n"); 404 - snic_stats_debugfs_remove(snic); 405 - } 400 + snic_stats_debugfs_init(snic); 406 401 #endif 407 402 408 403 /* Setup PCI Resources */ ··· 845 850 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS 846 851 /* Debugfs related Initialization */ 847 852 /* Create debugfs entries for snic */ 848 - ret = snic_debugfs_init(); 849 - if (ret < 0) { 850 - SNIC_ERR("Failed to create sysfs dir for tracing and stats.\n"); 851 - snic_debugfs_term(); 852 - /* continue even if it fails */ 853 - } 853 + snic_debugfs_init(); 854 854 855 855 /* Trace related Initialization */ 856 856 /* Allocate memory for trace buffer */
+1 -1
drivers/scsi/snic/snic_stats.h
··· 99 99 atomic64_t io_cmpl_skip; 100 100 }; 101 101 102 - int snic_stats_debugfs_init(struct snic *); 102 + void snic_stats_debugfs_init(struct snic *); 103 103 void snic_stats_debugfs_remove(struct snic *); 104 104 105 105 /* Auxillary function to update active IO counter */
+1 -11
drivers/scsi/snic/snic_trc.c
··· 138 138 trc->buf = (struct snic_trc_data *) tbuf; 139 139 spin_lock_init(&trc->lock); 140 140 141 - ret = snic_trc_debugfs_init(); 142 - if (ret) { 143 - SNIC_ERR("Failed to create Debugfs Files.\n"); 144 - 145 - goto error; 146 - } 141 + snic_trc_debugfs_init(); 147 142 148 143 trc->max_idx = (tbuf_sz / SNIC_TRC_ENTRY_SZ); 149 144 trc->rd_idx = trc->wr_idx = 0; ··· 146 151 SNIC_INFO("Trace Facility Enabled.\n Trace Buffer SZ %lu Pages.\n", 147 152 tbuf_sz / PAGE_SIZE); 148 153 ret = 0; 149 - 150 - return ret; 151 - 152 - error: 153 - snic_trc_free(); 154 154 155 155 return ret; 156 156 } /* end of snic_trc_init */
+2 -2
drivers/scsi/snic/snic_trc.h
··· 53 53 54 54 int snic_trc_init(void); 55 55 void snic_trc_free(void); 56 - int snic_trc_debugfs_init(void); 56 + void snic_trc_debugfs_init(void); 57 57 void snic_trc_debugfs_term(void); 58 58 struct snic_trc_data *snic_get_trc_buf(void); 59 59 int snic_get_trc_data(char *buf, int buf_sz); 60 60 61 - int snic_debugfs_init(void); 61 + void snic_debugfs_init(void); 62 62 void snic_debugfs_term(void); 63 63 64 64 static inline void