diff mbox series

[v2] usb: dwc3: gadget: clear gadget pointer after exit

Message ID 1631179952-28023-1-git-send-email-quic_linyyuan@quicinc.com (mailing list archive)
State Superseded
Headers show
Series [v2] usb: dwc3: gadget: clear gadget pointer after exit | expand

Commit Message

Linyu Yuan Sept. 9, 2021, 9:32 a.m. UTC
when do role switch from device to host mode,
first disable device mode, currently there is no better way to
confirm when gadget was complete removed.

change device release function to clear gadget pointer,
this will confirm device stop complete when it is NULL.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
v2: fix comment from Greg Kroah-Hartman and improve commit log

 drivers/usb/dwc3/gadget.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Greg KH Sept. 9, 2021, 9:46 a.m. UTC | #1
On Thu, Sep 09, 2021 at 05:32:32PM +0800, Linyu Yuan wrote:
> when do role switch from device to host mode,
> first disable device mode, currently there is no better way to
> confirm when gadget was complete removed.
> 
> change device release function to clear gadget pointer,
> this will confirm device stop complete when it is NULL.

Where is this check happening?  If there is nothing in the tree today
that checks for this, why is this needed?

Does this fix a specific commit in the past?  If so, what one?

thanks,

greg k-h
Linyu Yuan Sept. 9, 2021, 10:14 a.m. UTC | #2
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Sent: Thursday, September 9, 2021 5:47 PM
> To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>
> Cc: Felipe Balbi <balbi@kernel.org>; linux-usb@vger.kernel.org
> Subject: Re: [PATCH v2] usb: dwc3: gadget: clear gadget pointer after exit
> 
> On Thu, Sep 09, 2021 at 05:32:32PM +0800, Linyu Yuan wrote:
> > when do role switch from device to host mode,
> > first disable device mode, currently there is no better way to
> > confirm when gadget was complete removed.
> >
> > change device release function to clear gadget pointer,
> > this will confirm device stop complete when it is NULL.
> 
> Where is this check happening?  If there is nothing in the tree today
> that checks for this, why is this needed?
> 
> Does this fix a specific commit in the past?  If so, what one?
It is only my private usage, it is not fix a previous commit.

In theory this change have no harm and improve.
If you and Felipe both can't approve it, I can accept it.
Anyway thanks for your time.

> 
> thanks,
> 
> greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 804b505..e2ab5f6 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -4188,9 +4188,10 @@  static int dwc3_gadget_get_irq(struct dwc3 *dwc)
 
 static void dwc_gadget_release(struct device *dev)
 {
-	struct usb_gadget *gadget = container_of(dev, struct usb_gadget, dev);
+	struct dwc3 *dwc = dev_get_platdata(dev);
 
-	kfree(gadget);
+	kfree(dwc->gadget);
+	dwc->gadget = NULL;
 }
 
 /**