Skip to content

Commit 32e8441

Browse files
Felipe BalbiZhengShunQian
authored andcommitted
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 0e3e975)
1 parent 4e1f7dc commit 32e8441

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/usb/gadget/composite.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ void usb_remove_function(struct usb_configuration *c, struct usb_function *f)
263263
list_del(&f->list);
264264
if (f->unbind)
265265
f->unbind(c, f);
266+
267+
if (f->bind_deactivated)
268+
usb_function_activate(f);
266269
}
267270
EXPORT_SYMBOL_GPL(usb_remove_function);
268271

@@ -866,12 +869,8 @@ static void remove_config(struct usb_composite_dev *cdev,
866869

867870
f = list_first_entry(&config->functions,
868871
struct usb_function, list);
869-
list_del(&f->list);
870-
if (f->unbind) {
871-
DBG(cdev, "unbind function '%s'/%p\n", f->name, f);
872-
f->unbind(config, f);
873-
/* may free memory for "f" */
874-
}
872+
873+
usb_remove_function(config, f);
875874
}
876875
list_del(&config->list);
877876
if (config->unbind) {

drivers/usb/gadget/configfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,9 @@ static void purge_configs_funcs(struct gadget_info *gi)
12551255
" '%s'/%p\n", f->name, f);
12561256
f->unbind(c, f);
12571257
}
1258+
1259+
if (f->bind_deactivated)
1260+
usb_function_activate(f);
12581261
}
12591262
c->next_interface_id = 0;
12601263
memset(c->interface, 0, sizeof(c->interface));

0 commit comments

Comments
 (0)