ANDROID: usb: f_fs: Prevent gadget unbind if it is already unbound
authorHemant Kumar <hemantk@codeaurora.org>
Mon, 8 Aug 2016 23:20:15 +0000 (16:20 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Mon, 8 Jan 2018 17:04:06 +0000 (09:04 -0800)
Upon usb composition switch there is possibility of ep0 file
release happening after gadget driver bind. In case of composition
switch from adb to a non-adb composition gadget will never gets
bound again resulting into failure of usb device enumeration. Fix
this issue by checking FFS_FL_BOUND flag and avoid extra
gadget driver unbind if it is already done as part of composition
switch.

Change-Id: I1638001ff4a94f08224b188aa42425f3d732fa2b
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
drivers/usb/gadget/function/f_fs.c

index 39bb65265bff3e52c2c3ca2a944a04da60976a45..eb298daf49c721db9beb046802403e49de696dc3 100644 (file)
@@ -3490,7 +3490,8 @@ static void ffs_closed(struct ffs_data *ffs)
        ci = opts->func_inst.group.cg_item.ci_parent->ci_parent;
        ffs_dev_unlock();
 
-       unregister_gadget_item(ci);
+       if (test_bit(FFS_FL_BOUND, &ffs->flags))
+               unregister_gadget_item(ci);
        return;
 done:
        ffs_dev_unlock();