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

USB: ohci: 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.

There is also no need to keep the file dentries around at all, so remove
those variables from the host controller structure.

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+9 -44
+9 -36
drivers/usb/host/ohci-dbg.c
··· 762 762 static inline void create_debug_files (struct ohci_hcd *ohci) 763 763 { 764 764 struct usb_bus *bus = &ohci_to_hcd(ohci)->self; 765 + struct dentry *root; 765 766 766 - ohci->debug_dir = debugfs_create_dir(bus->bus_name, ohci_debug_root); 767 - if (!ohci->debug_dir) 768 - goto dir_error; 767 + root = debugfs_create_dir(bus->bus_name, ohci_debug_root); 768 + ohci->debug_dir = root; 769 769 770 - ohci->debug_async = debugfs_create_file("async", S_IRUGO, 771 - ohci->debug_dir, ohci, 772 - &debug_async_fops); 773 - if (!ohci->debug_async) 774 - goto async_error; 775 - 776 - ohci->debug_periodic = debugfs_create_file("periodic", S_IRUGO, 777 - ohci->debug_dir, ohci, 778 - &debug_periodic_fops); 779 - if (!ohci->debug_periodic) 780 - goto periodic_error; 781 - 782 - ohci->debug_registers = debugfs_create_file("registers", S_IRUGO, 783 - ohci->debug_dir, ohci, 784 - &debug_registers_fops); 785 - if (!ohci->debug_registers) 786 - goto registers_error; 770 + debugfs_create_file("async", S_IRUGO, root, ohci, &debug_async_fops); 771 + debugfs_create_file("periodic", S_IRUGO, root, ohci, 772 + &debug_periodic_fops); 773 + debugfs_create_file("registers", S_IRUGO, root, ohci, 774 + &debug_registers_fops); 787 775 788 776 ohci_dbg (ohci, "created debug files\n"); 789 - return; 790 - 791 - registers_error: 792 - debugfs_remove(ohci->debug_periodic); 793 - periodic_error: 794 - debugfs_remove(ohci->debug_async); 795 - async_error: 796 - debugfs_remove(ohci->debug_dir); 797 - dir_error: 798 - ohci->debug_periodic = NULL; 799 - ohci->debug_async = NULL; 800 - ohci->debug_dir = NULL; 801 777 } 802 778 803 779 static inline void remove_debug_files (struct ohci_hcd *ohci) 804 780 { 805 - debugfs_remove(ohci->debug_registers); 806 - debugfs_remove(ohci->debug_periodic); 807 - debugfs_remove(ohci->debug_async); 808 - debugfs_remove(ohci->debug_dir); 781 + debugfs_remove_recursive(ohci->debug_dir); 809 782 } 810 783 811 784 /*-------------------------------------------------------------------------*/
-5
drivers/usb/host/ohci-hcd.c
··· 1258 1258 set_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1259 1259 1260 1260 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root); 1261 - if (!ohci_debug_root) { 1262 - retval = -ENOENT; 1263 - goto error_debug; 1264 - } 1265 1261 1266 1262 #ifdef PS3_SYSTEM_BUS_DRIVER 1267 1263 retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER); ··· 1314 1318 #endif 1315 1319 debugfs_remove(ohci_debug_root); 1316 1320 ohci_debug_root = NULL; 1317 - error_debug: 1318 1321 1319 1322 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1320 1323 return retval;
-3
drivers/usb/host/ohci.h
··· 431 431 struct work_struct nec_work; /* Worker for NEC quirk */ 432 432 433 433 struct dentry *debug_dir; 434 - struct dentry *debug_async; 435 - struct dentry *debug_periodic; 436 - struct dentry *debug_registers; 437 434 438 435 /* platform-specific data -- must come last */ 439 436 unsigned long priv[0] __aligned(sizeof(s64));