All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: [01/22] USB: typec: tcpm: no need to check return value of debugfs_create_dir()
Date: Wed, 30 May 2018 13:30:20 +0300	[thread overview]
Message-ID: <20180530103020.GI29600@kuha.fi.intel.com> (raw)

+Guenter

On Tue, May 29, 2018 at 05:30:46PM +0200, Greg Kroah-Hartman wrote:
> 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.c code to not care about this, turns out no one was
> even checking the return value of this function, so it didn't matter.
> 
> 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 <heikki.krogerus@linux.intel.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Revieved-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 0ccd2ce1eb59..8a201dd53d36 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -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
> -- 
> 2.17.0

Thanks,

             reply	other threads:[~2018-05-30 10:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 10:30 Heikki Krogerus [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-31 10:52 [01/22] USB: typec: tcpm: no need to check return value of debugfs_create_dir() Greg Kroah-Hartman
2018-05-30 13:42 Guenter Roeck
2018-05-30 13:35 Guenter Roeck
2018-05-30 10:36 Greg Kroah-Hartman
2018-05-29 15:30 Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180530103020.GI29600@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.