From 8b8a942bd12d03091b6e741ded03c5db24f97f73 Mon Sep 17 00:00:00 2001 From: Chandana Kishori Chiluveru Date: Mon, 18 Jun 2018 17:23:18 +0530 Subject: [PATCH] usb: gadget: configfs: Correct usb functions order for UDC gadget bind During multiple adb reboots test case, adbd is taking time to start and write the descriptors from the userspace. If adb is their in the composition and its not ready when bind happens, UDC bind for ffs will fail and adding the function back to the func_list in failure path and calling purge_configs_funcs. In purge_func adb driver unbind the functions from config->functions list and add back to the tail of the func_list. With this order of the functions in func_list got changed and next time when bind happens from adbd start usb does not working. Fix this issue by changing the order of the functions while adding the functions back to the list in purge_configs_funcs. Change-Id: I50c2362062130836d66edfcf8e1f020134248cb4 Signed-off-by: Chandana Kishori Chiluveru --- drivers/usb/gadget/configfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 1a2af68ca93d..a31322ed9447 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1259,9 +1259,9 @@ static void purge_configs_funcs(struct gadget_info *gi) cfg = container_of(c, struct config_usb_cfg, c); - list_for_each_entry_safe(f, tmp, &c->functions, list) { + list_for_each_entry_safe_reverse(f, tmp, &c->functions, list) { - list_move_tail(&f->list, &cfg->func_list); + list_move(&f->list, &cfg->func_list); if (f->unbind) { dev_err(&gi->cdev.gadget->dev, "unbind function" " '%s'/%pK\n", f->name, f);