Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1622183
| From | Alan Stern <stern@rowland.harvard.edu> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device |
| Date | 2017-04-12 16:40 +0200 |
| Message-ID | <tvrB8-5Bn-9@gated-at.bofh.it> (permalink) |
| References | <tvjDz-Xu-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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 qualify.
> >
> > Aw, I wanted to publically yell at someone like the kernel documentation
> > says I am allowed to do so if anyone does such a foolish thing :)
>
> heh, except that we're not dynamically allocating struct device at all
> :-) Here's what we have for most UDCs (net2280.c included):
>
> struct my_udc {
> struct gadget gadget;
> [...]
> };
>
> probe()
> {
> struct my_udc *u;
>
> u = kzalloc(sizeof(*u), GFP_KERNEL);
> [...]
> return 0;
> }
Allow me to point out that the struct device is embedded inside the
struct gadget (actually struct usb_gadget) embedded inside the struct
my_udc, which _is_ dynamically allocated. Therefore the struct device
is located in dynamically allocated memory.
> Now, if this kzalloc() would be replaced with devm_kzalloc() wouldn't
> this result on a functionally equivalent execution to the patch I
> proposed above?
It would, and it would be equally wrong.
Alan Stern
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Alan Stern <stern@rowland.harvard.edu> - 2017-04-10 17:20 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Felipe Balbi <balbi@kernel.org> - 2017-04-11 09:40 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Alan Stern <stern@rowland.harvard.edu> - 2017-04-11 16:20 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Greg KH <greg@kroah.com> - 2017-04-11 16:20 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Felipe Balbi <balbi@kernel.org> - 2017-04-12 08:10 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Greg KH <greg@kroah.com> - 2017-04-12 08:50 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Felipe Balbi <balbi@kernel.org> - 2017-04-12 09:40 +0200
Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device Alan Stern <stern@rowland.harvard.edu> - 2017-04-12 16:40 +0200
csiph-web