From: Sebastian Andrzej Siewior Date: Sun, 23 Dec 2012 20:10:05 +0000 (+0100) Subject: usb: gadget: composite: add usb_remove_function() X-Git-Tag: upstream/snapshot3+hdmi~5695^2~43^2~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b473577854fea63055ff9ab84f0f52a3e8aed15e;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git usb: gadget: composite: add usb_remove_function() This will be used to remove a single function from a given config. Right now "ignore" that an error at ->bind() time and cleanup later during composite_unbind() / remove_config(). Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 4aa0e46..366facc 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -215,6 +215,18 @@ done: } EXPORT_SYMBOL_GPL(usb_add_function); +void usb_remove_function(struct usb_configuration *c, struct usb_function *f) +{ + if (f->disable) + f->disable(f); + + bitmap_zero(f->endpoints, 32); + list_del(&f->list); + if (f->unbind) + f->unbind(c, f); +} +EXPORT_SYMBOL_GPL(usb_remove_function); + /** * usb_function_deactivate - prevent function and gadget enumeration * @function: the function that isn't yet ready to respond diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 3834e33..8c7a629 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -461,6 +461,7 @@ struct usb_configuration *usb_get_config(struct usb_composite_dev *cdev, int val); int usb_add_config_only(struct usb_composite_dev *cdev, struct usb_configuration *config); +void usb_remove_function(struct usb_configuration *c, struct usb_function *f); #define DECLARE_USB_FUNCTION(_name, _inst_alloc, _func_alloc) \ static struct usb_function_driver _name ## usb_func = { \