From 35fdb9cd7e90c08ac9697fa330e4e290b9d34f8a Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Mon, 8 Aug 2016 16:20:15 -0700 Subject: [PATCH] usb: f_fs: Prevent gadget unbind if it is already unbound 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 --- drivers/usb/gadget/function/f_fs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 54a293a93aec..c5fd3ce3ed9a 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -3968,10 +3968,11 @@ static void ffs_closed(struct ffs_data *ffs) ffs_dev_unlock(); - unregister_gadget_item(opts-> + if (test_bit(FFS_FL_BOUND, &ffs->flags)) { + unregister_gadget_item(opts-> func_inst.group.cg_item.ci_parent->ci_parent); - - ffs_log("unreg gadget done"); + ffs_log("unreg gadget done"); + } done: ffs_log("exit"); }