From: Felipe Balbi <balbi@kernel.org>
To: changbin.du@intel.com
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, "Du\,
Changbin" <changbin.du@intel.com>
Subject: Re: [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void
Date: Mon, 11 Apr 2016 11:14:26 +0300 [thread overview]
Message-ID: <878u0kpnod.fsf@intel.com> (raw)
In-Reply-To: <1460108062-31398-2-git-send-email-changbin.du@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2352 bytes --]
Hi,
changbin.du@intel.com writes:
> diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
> index 07fbc2d..71e3180 100644
> --- a/drivers/usb/dwc3/debug.h
> +++ b/drivers/usb/dwc3/debug.h
> @@ -217,11 +217,11 @@ static inline const char *dwc3_gadget_event_type_string(u8 event)
> void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...);
>
> #ifdef CONFIG_DEBUG_FS
> -extern int dwc3_debugfs_init(struct dwc3 *);
> +extern void dwc3_debugfs_init(struct dwc3 *);
> extern void dwc3_debugfs_exit(struct dwc3 *);
> #else
> -static inline int dwc3_debugfs_init(struct dwc3 *d)
> -{ return 0; }
> +static inline void dwc3_debugfs_init(struct dwc3 *d)
> +{ }
> static inline void dwc3_debugfs_exit(struct dwc3 *d)
> { }
> #endif
> diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
> index 9ac37fe..071b286 100644
> --- a/drivers/usb/dwc3/debugfs.c
> +++ b/drivers/usb/dwc3/debugfs.c
> @@ -618,69 +618,39 @@ static const struct file_operations dwc3_link_state_fops = {
> .release = single_release,
> };
>
> -int dwc3_debugfs_init(struct dwc3 *dwc)
> +void dwc3_debugfs_init(struct dwc3 *dwc)
> {
> struct dentry *root;
> - struct dentry *file;
> - int ret;
>
> root = debugfs_create_dir(dev_name(dwc->dev), NULL);
> - if (!root) {
> - ret = -ENOMEM;
> - goto err0;
> - }
> + if (IS_ERR_OR_NULL(root))
> + return;
We can definitely keep on going, but I'd still like to know that we
enabled CONFIG_DEBUG_FS but failed to create a file or a
directory. Seems like this should read as follows:
if (IS_ERR_OR_NULL(root)) {
if (!root)
dev_err(dwc->dev, "Can't create debugfs root\n");
return;
}
ditto to all bellow.
> dwc->root = root;
>
> dwc->regset = kzalloc(sizeof(*dwc->regset), GFP_KERNEL);
> if (!dwc->regset) {
> - ret = -ENOMEM;
> - goto err1;
> + debugfs_remove_recursive(root);
you're now duplicating debugfs_remove_recursive(root) in all braches and
that's error prone. It's probably better to keep our gotos, but change
them so they read as follows:
if (!dwc->regset)
goto err1;
[...]
return; /* this is our successful exit point */
err1:
debugfs_remove_recursive(root);
kfree(dwc->regset);
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next prev parent reply other threads:[~2016-04-11 8:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 8:27 [PATCH] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du
2016-04-06 9:25 ` Greg KH
2016-04-06 11:38 ` Du, Changbin
2016-04-06 12:24 ` Felipe Balbi
2016-04-06 15:44 ` [PATCH v2 0/3] Improvement, fix and new entry for dwc3 debugfs changbin.du
2016-04-07 5:05 ` Felipe Balbi
2016-04-07 5:21 ` Du, Changbin
2016-04-07 5:22 ` Felipe Balbi
2016-04-08 9:34 ` [PATCH v3 0/2] Add a new debugfs entry to dump FIFO/Queue available space changbin.du
2016-04-08 9:34 ` [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void changbin.du
2016-04-11 8:14 ` Felipe Balbi [this message]
2016-04-11 11:19 ` Du, Changbin
2016-04-11 11:23 ` Felipe Balbi
2016-04-12 11:10 ` [PATCH v4 0/2] Add a new debugfs entry to dump FIFO/Queue available space changbin.du
2016-04-12 11:10 ` [PATCH v4 1/2] usb: dwc3: make dwc3_debugfs_init return value be void changbin.du
2016-04-12 11:10 ` [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du
2016-04-12 12:58 ` Sergei Shtylyov
2016-04-14 3:27 ` Du, Changbin
2016-04-14 8:02 ` Felipe Balbi
2016-04-14 11:15 ` Du, Changbin
2016-04-14 11:18 ` Felipe Balbi
2016-04-14 11:37 ` Du, Changbin
2016-04-14 11:41 ` Felipe Balbi
2016-04-14 11:58 ` Du, Changbin
2016-04-08 9:34 ` [PATCH v3 " changbin.du
2016-04-06 15:44 ` [PATCH v2 1/3] usb: dwc3: make dwc3_debugfs_init return value be void changbin.du
2016-04-06 15:44 ` [PATCH v2 2/3] usb: dwc3: free dwc->regset on dwc3_debugfs_exit changbin.du
2016-04-06 21:08 ` Greg KH
2016-04-07 5:05 ` Felipe Balbi
2016-04-06 15:44 ` [PATCH v2 3/3] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du
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=878u0kpnod.fsf@intel.com \
--to=balbi@kernel.org \
--cc=changbin.du@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).