Commit b4735778 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 3249ca22
...@@ -215,6 +215,18 @@ int usb_add_function(struct usb_configuration *config, ...@@ -215,6 +215,18 @@ int usb_add_function(struct usb_configuration *config,
} }
EXPORT_SYMBOL_GPL(usb_add_function); 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 * usb_function_deactivate - prevent function and gadget enumeration
* @function: the function that isn't yet ready to respond * @function: the function that isn't yet ready to respond
......
...@@ -461,6 +461,7 @@ struct usb_configuration *usb_get_config(struct usb_composite_dev *cdev, ...@@ -461,6 +461,7 @@ struct usb_configuration *usb_get_config(struct usb_composite_dev *cdev,
int val); int val);
int usb_add_config_only(struct usb_composite_dev *cdev, int usb_add_config_only(struct usb_composite_dev *cdev,
struct usb_configuration *config); 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) \ #define DECLARE_USB_FUNCTION(_name, _inst_alloc, _func_alloc) \
static struct usb_function_driver _name ## usb_func = { \ static struct usb_function_driver _name ## usb_func = { \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment