From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Felipe Balbi <balbi@kernel.org>
Subject: [17/22] USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions
Date: Wed, 30 May 2018 19:31:13 +0200 [thread overview]
Message-ID: <20180530173113.GA2763@piout.net> (raw)
Hi,
On 29/05/2018 17:31:02+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.
>
> There is also no need to keep the file dentries around at all, so remove
> those variables from the device structure.
>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/usb/gadget/udc/atmel_usba_udc.c | 71 ++++---------------------
> drivers/usb/gadget/udc/atmel_usba_udc.h | 4 --
> 2 files changed, 11 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 2f586f2bda7e..a4d99bf50f2f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -206,94 +206,45 @@ static void usba_ep_init_debugfs(struct usba_udc *udc,
> struct dentry *ep_root;
>
> ep_root = debugfs_create_dir(ep->ep.name, udc->debugfs_root);
> - if (!ep_root)
> - goto err_root;
> ep->debugfs_dir = ep_root;
>
> - ep->debugfs_queue = debugfs_create_file("queue", 0400, ep_root,
> - ep, &queue_dbg_fops);
> - if (!ep->debugfs_queue)
> - goto err_queue;
> -
> - if (ep->can_dma) {
> - ep->debugfs_dma_status
> - = debugfs_create_u32("dma_status", 0400, ep_root,
> - &ep->last_dma_status);
> - if (!ep->debugfs_dma_status)
> - goto err_dma_status;
> - }
> - if (ep_is_control(ep)) {
> - ep->debugfs_state
> - = debugfs_create_u32("state", 0400, ep_root,
> - &ep->state);
> - if (!ep->debugfs_state)
> - goto err_state;
> - }
> -
> - return;
> -
> -err_state:
> + debugfs_create_file("queue", 0400, ep_root, ep, &queue_dbg_fops);
What happens here if debugfs_create_dir returned NULL? I guess the file
will be placed at the root of the debugfs filesystem which is not great.
Should we stop caring about that and assume that if debugfs_create_dir,
the following debugfs_create_* calls will fail?
next reply other threads:[~2018-05-30 17:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-30 17:31 Alexandre Belloni [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-05-31 10:50 [17/22] USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2018-05-30 18:20 Alexandre Belloni
2018-05-30 18:06 Greg Kroah-Hartman
2018-05-29 15:31 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=20180530173113.GA2763@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
/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).