All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] usb: dwc3: gadget: clear gadget pointer after exit
@ 2021-09-09  9:32 Linyu Yuan
  2021-09-09  9:46 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Linyu Yuan @ 2021-09-09  9:32 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman; +Cc: linux-usb, Linyu Yuan

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(-)

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;
 }
 
 /**
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: dwc3: gadget: clear gadget pointer after exit
  2021-09-09  9:32 [PATCH v2] usb: dwc3: gadget: clear gadget pointer after exit Linyu Yuan
@ 2021-09-09  9:46 ` Greg Kroah-Hartman
  2021-09-09 10:14   ` Linyu Yuan (QUIC)
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2021-09-09  9:46 UTC (permalink / raw)
  To: Linyu Yuan; +Cc: Felipe Balbi, linux-usb

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v2] usb: dwc3: gadget: clear gadget pointer after exit
  2021-09-09  9:46 ` Greg Kroah-Hartman
@ 2021-09-09 10:14   ` Linyu Yuan (QUIC)
  0 siblings, 0 replies; 3+ messages in thread
From: Linyu Yuan (QUIC) @ 2021-09-09 10:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Linyu Yuan (QUIC); +Cc: Felipe Balbi, linux-usb

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-09 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09  9:32 [PATCH v2] usb: dwc3: gadget: clear gadget pointer after exit Linyu Yuan
2021-09-09  9:46 ` Greg Kroah-Hartman
2021-09-09 10:14   ` Linyu Yuan (QUIC)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.