Skip to contentSkip to conversation

USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions

PATCH New Greg Kroah-Hartman 1 participant 1 message May 30, 2018 USB

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 17/22 USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions

Quoted 50 lines · Alexandre Belloni

Hi,

Quoted 47 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.

There is also no need to keep the file dentries around at all, so remove those variables from the device structure.

Cc Nicolas Ferre <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Alexandre Belloni <[email protected]>
---
 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(-)
drivers/usb/gadget/udc/atmel_usba_udc.c +0 -21
index 2f586f2bda7e..a4d99bf50f2f 100644
@@ -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;
-	}
Quoted 8 lines

drivers/usb/gadget/udc/atmel_usba_udc.c static void usba_ep_init_debugfs(struct usba_udc *udc, · line 211

Quoted 5 lines
drivers/usb/gadget/udc/atmel_usba_udc.c +1 -4
-
-	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.

It doesn't really matter :)

The only way it can return NULL is if something really bad happens to debugfs, and if that occurs, no one cares. The function can only return NULL if you pass a bad dentry into it, or if the directory is being removed at that exact point in time. Either of which are bigger issues and then who cares what happens in debugfs.

No normal code should ever change its functionality based on if debugfs is working or not.

Quoted 2 lines

Should we stop caring about that and assume that if debugfs_create_dir, the following debugfs_create_* calls will fail?

Yes. You should not care :)

thanks,

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html