Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-12 Thread Alan Stern
On Wed, 12 Apr 2017, Felipe Balbi wrote: > >> Maybe... But I can't shake the feeling that Greg KH would strongly > >> disagree. Hasn't he said, many times in the past, that any dynamically > >> allocated device structure _must_ have a real release routine? > >> usb_udc_nop_release() doesn't

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-12 Thread Felipe Balbi
Hi, Greg KH writes: >> Here's what we have for most UDCs (net2280.c included): >> >> struct my_udc { >> struct gadget gadget; >> [...] >> }; >> >> probe() >> { >> struct my_udc *u; >> >> u =

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-12 Thread Greg KH
On Wed, Apr 12, 2017 at 09:01:44AM +0300, Felipe Balbi wrote: > > Hi, > > Greg KH writes: > > On Tue, Apr 11, 2017 at 10:12:01AM -0400, Alan Stern wrote: > >> On Tue, 11 Apr 2017, Felipe Balbi wrote: > >> > >> > > Oddly enough, yes. But it doesn't explain why this code doesn't

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-12 Thread Felipe Balbi
Hi, Greg KH writes: > On Tue, Apr 11, 2017 at 10:12:01AM -0400, Alan Stern wrote: >> On Tue, 11 Apr 2017, Felipe Balbi wrote: >> >> > > Oddly enough, yes. But it doesn't explain why this code doesn't blow >> > > up every time it gets called, in its current form. >> > >> >

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-11 Thread Greg KH
On Tue, Apr 11, 2017 at 10:12:01AM -0400, Alan Stern wrote: > On Tue, 11 Apr 2017, Felipe Balbi wrote: > > > > Oddly enough, yes. But it doesn't explain why this code doesn't blow > > > up every time it gets called, in its current form. > > > > Well, it does :-) > > > > dev_get_drvdata(_dev)

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-11 Thread Alan Stern
On Tue, 11 Apr 2017, Felipe Balbi wrote: > > Oddly enough, yes. But it doesn't explain why this code doesn't blow > > up every time it gets called, in its current form. > > Well, it does :-) > > dev_get_drvdata(_dev) -> NULL -> kfree(NULL) > > We're just leaking memory. I guess a patch like

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-11 Thread Felipe Balbi
Hi, Alan Stern writes: >> >> >> >> --- a/drivers/usb/gadget/udc/core.c >> >> >> >> +++ b/drivers/usb/gadget/udc/core.c >> >> >> >> @@ -1273,6 +1273,7 @@ void usb_del_gadget_udc(struct usb_gadget >> >> >> >> *gadget) >> >> >> >> flush_work(>work); >> >> >> >>

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-10 Thread Alan Stern
On Mon, 10 Apr 2017, Felipe Balbi wrote: > Hi, > > Alan Stern writes: > > On Wed, 5 Apr 2017, Felipe Balbi wrote: > > > >> >> >> --- a/drivers/usb/gadget/udc/core.c > >> >> >> +++ b/drivers/usb/gadget/udc/core.c > >> >> >> @@ -1273,6 +1273,7 @@ void

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-10 Thread Felipe Balbi
Hi, Alan Stern writes: > On Wed, 5 Apr 2017, Felipe Balbi wrote: > >> >> >> --- a/drivers/usb/gadget/udc/core.c >> >> >> +++ b/drivers/usb/gadget/udc/core.c >> >> >> @@ -1273,6 +1273,7 @@ void usb_del_gadget_udc(struct usb_gadget >> >> >> *gadget) >> >> >>

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-05 Thread Alan Stern
On Wed, 5 Apr 2017, Felipe Balbi wrote: > >> >> --- a/drivers/usb/gadget/udc/core.c > >> >> +++ b/drivers/usb/gadget/udc/core.c > >> >> @@ -1273,6 +1273,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) > >> >> flush_work(>work); > >> >> device_unregister(>dev); > >> >>

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-05 Thread Felipe Balbi
Hi, Alan Stern writes: >> >> allow usb_del_gadget_udc() and usb add_gadget_udc() to be called >> >> repeatedly on the same gadget->dev structure. >> >> >> >> We need to clear the gadget->dev structure so that kobject_init() >> >> doesn't complain about already

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-04 Thread Alan Stern
On Tue, 4 Apr 2017, Felipe Balbi wrote: > Hi, > > Alan Stern writes: > > On Mon, 3 Apr 2017, Roger Quadros wrote: > > > >> allow usb_del_gadget_udc() and usb add_gadget_udc() to be called > >> repeatedly on the same gadget->dev structure. > >> > >> We need to clear

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-04 Thread Felipe Balbi
Hi, Alan Stern writes: > On Mon, 3 Apr 2017, Roger Quadros wrote: > >> allow usb_del_gadget_udc() and usb add_gadget_udc() to be called >> repeatedly on the same gadget->dev structure. >> >> We need to clear the gadget->dev structure so that kobject_init() >> doesn't

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-03 Thread Alan Stern
On Mon, 3 Apr 2017, Roger Quadros wrote: > allow usb_del_gadget_udc() and usb add_gadget_udc() to be called > repeatedly on the same gadget->dev structure. > > We need to clear the gadget->dev structure so that kobject_init() > doesn't complain about already initialized object. > >