mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 11:50:43 +09:00
BACKPORT: usb: gadget: composite: make sure to reactivate function on unbind
If a function sets bind_deactivated flag, upon removal we will be left
with an unbalanced deactivation. Let's make sure that we conditionally
call usb_function_activate() from usb_remove_function() and make sure
usb_remove_function() is called from remove_config().
Change-Id: I4d7a70560961da90561a7999ac4e58a294c1a0cf
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 0e3e97526a)
This commit is contained in:
@@ -263,6 +263,9 @@ void usb_remove_function(struct usb_configuration *c, struct usb_function *f)
|
||||
list_del(&f->list);
|
||||
if (f->unbind)
|
||||
f->unbind(c, f);
|
||||
|
||||
if (f->bind_deactivated)
|
||||
usb_function_activate(f);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_remove_function);
|
||||
|
||||
@@ -866,12 +869,8 @@ static void remove_config(struct usb_composite_dev *cdev,
|
||||
|
||||
f = list_first_entry(&config->functions,
|
||||
struct usb_function, list);
|
||||
list_del(&f->list);
|
||||
if (f->unbind) {
|
||||
DBG(cdev, "unbind function '%s'/%p\n", f->name, f);
|
||||
f->unbind(config, f);
|
||||
/* may free memory for "f" */
|
||||
}
|
||||
|
||||
usb_remove_function(config, f);
|
||||
}
|
||||
list_del(&config->list);
|
||||
if (config->unbind) {
|
||||
|
||||
@@ -1255,6 +1255,9 @@ static void purge_configs_funcs(struct gadget_info *gi)
|
||||
" '%s'/%p\n", f->name, f);
|
||||
f->unbind(c, f);
|
||||
}
|
||||
|
||||
if (f->bind_deactivated)
|
||||
usb_function_activate(f);
|
||||
}
|
||||
c->next_interface_id = 0;
|
||||
memset(c->interface, 0, sizeof(c->interface));
|
||||
|
||||
Reference in New Issue
Block a user