On Fri, 2017-06-09 at 21:00 +1000, Benjamin Herrenschmidt wrote:
> Hi !
>
> So for the aspeed virtual hub, I'm in a situation where I have up to 5
> devices sharing a pool of 15 "generic" endpoints (not counting EP0's,
> those have dedicated HW).
>
> I was originally thinking of having some device-tree construct
> assigning fixed number of EPs from the pool to the various devices, but
> that sucks...
>
> I'm trying to figure out if I can do something more dynamic.
>
> My idea is to not put the EPs in the gadget ep_list at first, but
> provide a match_ep() callback that effectively "allocates" an EP from
> the pool.
>
> It looks from a cursory glance at the code that it might work, with a
> reasonable failure mode since running out of EPs would typically make
> functions fail at bind() time.
>
> However we're missing a "free" :-)
>
> I *think* (please correct me if I'm wrong) that adding a callback for
> that and plumbing it this way would work, let me know what you think.
>
> If you agree with the approach (and it ends up working once I'm done
> coding), I'll submit it as a pre-req patch to the driver.
>
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index e4516e9..f8d2135 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -307,6 +307,7 @@ struct usb_gadget_ops {
> struct usb_ep *(*match_ep)(struct usb_gadget *,
> struct usb_endpoint_descriptor *,
> struct usb_ss_ep_comp_descriptor *);
> + void (*release_ep)(struct usb_gadget *, struct usb_ep *);
> };
Or rather in the ep->ops as we don't always have the struct usb_gadget
around when releasing, but you get the idea...
Cheers,
Ben.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html