USB: ohci: no need to check return value of debugfs_create functions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 May 2018 15:30:52 +0000 (17:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 May 2018 10:54:21 +0000 (12:54 +0200)
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>
drivers/usb/host/ohci-dbg.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/ohci.h

index ac7d4ac34b0221c38b2995d6b304ff886fb881b8..d3ee1f52aaab2dc42864fb1e3464fa1b8ff4fa4b 100644 (file)
@@ -762,50 +762,23 @@ static int debug_registers_open(struct inode *inode, struct file *file)
 static inline void create_debug_files (struct ohci_hcd *ohci)
 {
        struct usb_bus *bus = &ohci_to_hcd(ohci)->self;
+       struct dentry *root;
 
-       ohci->debug_dir = debugfs_create_dir(bus->bus_name, ohci_debug_root);
-       if (!ohci->debug_dir)
-               goto dir_error;
+       root = debugfs_create_dir(bus->bus_name, ohci_debug_root);
+       ohci->debug_dir = root;
 
-       ohci->debug_async = debugfs_create_file("async", S_IRUGO,
-                                               ohci->debug_dir, ohci,
-                                               &debug_async_fops);
-       if (!ohci->debug_async)
-               goto async_error;
-
-       ohci->debug_periodic = debugfs_create_file("periodic", S_IRUGO,
-                                                  ohci->debug_dir, ohci,
-                                                  &debug_periodic_fops);
-       if (!ohci->debug_periodic)
-               goto periodic_error;
-
-       ohci->debug_registers = debugfs_create_file("registers", S_IRUGO,
-                                                   ohci->debug_dir, ohci,
-                                                   &debug_registers_fops);
-       if (!ohci->debug_registers)
-               goto registers_error;
+       debugfs_create_file("async", S_IRUGO, root, ohci, &debug_async_fops);
+       debugfs_create_file("periodic", S_IRUGO, root, ohci,
+                           &debug_periodic_fops);
+       debugfs_create_file("registers", S_IRUGO, root, ohci,
+                           &debug_registers_fops);
 
        ohci_dbg (ohci, "created debug files\n");
-       return;
-
-registers_error:
-       debugfs_remove(ohci->debug_periodic);
-periodic_error:
-       debugfs_remove(ohci->debug_async);
-async_error:
-       debugfs_remove(ohci->debug_dir);
-dir_error:
-       ohci->debug_periodic = NULL;
-       ohci->debug_async = NULL;
-       ohci->debug_dir = NULL;
 }
 
 static inline void remove_debug_files (struct ohci_hcd *ohci)
 {
-       debugfs_remove(ohci->debug_registers);
-       debugfs_remove(ohci->debug_periodic);
-       debugfs_remove(ohci->debug_async);
-       debugfs_remove(ohci->debug_dir);
+       debugfs_remove_recursive(ohci->debug_dir);
 }
 
 /*-------------------------------------------------------------------------*/
index 4806e0f9e8d4c24db8c8a5fa4d6335109f90f6ba..210181fd98d2e9d6e850662becf6ec08f7b901c2 100644 (file)
@@ -1258,10 +1258,6 @@ static int __init ohci_hcd_mod_init(void)
        set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
 
        ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);
-       if (!ohci_debug_root) {
-               retval = -ENOENT;
-               goto error_debug;
-       }
 
 #ifdef PS3_SYSTEM_BUS_DRIVER
        retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
@@ -1318,7 +1314,6 @@ static int __init ohci_hcd_mod_init(void)
 #endif
        debugfs_remove(ohci_debug_root);
        ohci_debug_root = NULL;
- error_debug:
 
        clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
        return retval;
index 508a803139dd34fa80d53c2950886e49a9c74b6a..ef4813bfc5bf1c775162672563a9648bbbc1fc5a 100644 (file)
@@ -431,9 +431,6 @@ struct ohci_hcd {
        struct work_struct      nec_work;       /* Worker for NEC quirk */
 
        struct dentry           *debug_dir;
-       struct dentry           *debug_async;
-       struct dentry           *debug_periodic;
-       struct dentry           *debug_registers;
 
        /* platform-specific data -- must come last */
        unsigned long           priv[0] __aligned(sizeof(s64));