USB: typec: tcpm: no need to check return value of debugfs_create_dir()
PATCH 1/22 USB: typec: tcpm: no need to check return value of debugfs_create_dir()
+Guenter
Quoted 7 lines · Greg Kroah-Hartman
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.
Clean up the
tcpm.ccode to not care about this, turns out no one was even checking the return value of this function, so it didn't matter.
Quoted 6 lines
Note, I do not think this code can be removed in a running system, as the debugfs root directory will stick around, that should be fixed someday...
Cc Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Revieved-by Heikki Krogerus <[email protected]>
Quoted 43 lines
--- drivers/usb/typec/tcpm.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/usb/typec/tcpm.c +3
-8@@ -566,21 +566,16 @@ DEFINE_SHOW_ATTRIBUTE(tcpm_debug);static struct dentry *rootdir; -static int tcpm_debugfs_init (struct tcpm_port *port) +static void tcpm_debugfs_init (struct tcpm_port *port) {mutex_init (&port->logbuffer_lock);/* /sys/kernel/debug/tcpm/usbcX */ -if (!rootdir) { +if (!rootdir) rootdir =debugfs_create_dir ("tcpm" ,NULL ); -if (!rootdir) -return -ENOMEM ; - } port->dentry =debugfs_create_file (dev_name (port->dev),S_IFREG |0444 , rootdir, port, &tcpm_debug_fops); - -return 0 ; }static void tcpm_debugfs_exit (struct tcpm_port *port)@@ -595,7 +590,7 @@ static void tcpm_log(const struct tcpm_port *port, const char *fmt, ...) { } __printf(2, 3)static void tcpm_log_force (struct tcpm_port *port,const char *fmt, ...) { }static void tcpm_log_source_caps (struct tcpm_port *port) { } -static int tcpm_debugfs_init (const struct tcpm_port *port) {return 0 ; } +static void tcpm_debugfs_init (const struct tcpm_port *port) { }static void tcpm_debugfs_exit (const struct tcpm_port *port) { }#endif Signature · 1 line
2.17.0
Thanks,