Re: [PATCH] usb: dwc3: debugfs: Add and remove endpoint dirs dynamically
From: Jack Pham <hidden>
Date: 2021-06-01 16:09:56
Hi Peter, On Tue, Jun 01, 2021 at 03:07:44PM +0800, Peter Chen wrote: <snip>
quoted
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 65d9b7227752..dbba31d415d7 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c@@ -2754,6 +2754,8 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum) INIT_LIST_HEAD(&dep->started_list); INIT_LIST_HEAD(&dep->cancelled_list); + dwc3_debugfs_create_endpoint_dir(dep); + return 0; }@@ -2797,6 +2799,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) list_del(&dep->endpoint.ep_list); } + debugfs_remove_recursive(debugfs_lookup(dep->name, dwc->root));There is one more debugfs_remove_recursive at dwc3_debugfs_exit, need to delete?
No I think it should be fine. dwc3_debugfs_exit() is only called by dwc3_remove(), and at that time it removes the debugfs directory for the entire instance from dwc->root, which includes the parent and all the endpoint subdirectories if present. dwc3_core_exit_mode() -> dwc3_gadget_exit() is done after that, by which point the debugfs remove here at dwc3_gadget_free_endpoints() will be redundant and a no-op anyway. Thanks, Jack -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project