From e81a7018d93a7de31a3f121c9a7eecd0a5ec58b0 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Fri, 21 Aug 2020 10:55:48 +0800 Subject: usb: dwc3: allocate gadget structure dynamically The current code uses commit fac323471df6 ("usb: udc: allow adding and removing the same gadget device") as the workaround to let the gadget device is re-used, but it is not allowed from driver core point. In this commit, we allocate gadget structure dynamically, and free it at its release function. Since the gadget device's driver_data has already occupied by usb_composite_dev structure, we have to use gadget device's platform data to store dwc3 structure. Cc: Greg Kroah-Hartman Cc: Alan Stern Reviewed-by: Greg Kroah-Hartman Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/dwc3/gadget.h') diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index a7791cb827c4..0cd281949970 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -17,7 +17,7 @@ struct dwc3; #define to_dwc3_ep(ep) (container_of(ep, struct dwc3_ep, endpoint)) -#define gadget_to_dwc(g) (container_of(g, struct dwc3, gadget)) +#define gadget_to_dwc(g) (dev_get_platdata(&g->dev)) /* DEPCFG parameter 1 */ #define DWC3_DEPCFG_INT_NUM(n) (((n) & 0x1f) << 0) -- cgit v1.2.3