From: Hemant Kumar <hema...@codeaurora.org>

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.

This fixes adb reconnection error reported on Android running
v4.4 and above kernel versions. Verified on Hikey running vanilla
v4.15-rc7 + few out of tree Mali patches.

Reviewed-at: https://android-review.googlesource.com/#/c/582632/

Cc: Felipe Balbi <ba...@kernel.org>
Cc: Greg KH <gre...@linux-foundation.org>
Cc: Michal Nazarewicz <min...@mina86.com>
Cc: John Stultz <john.stu...@linaro.org>
Cc: Dmitry Shmidt <dimitr...@google.com>
Cc: Badhri <bad...@google.com>
Cc: Android Kernel Team <kernel-t...@android.com>
Cc: sta...@vger.kernel.org
Signed-off-by: Hemant Kumar <hema...@codeaurora.org>
[AmitP: Cherry-picked it from android-4.14 and updated the commit log]
Signed-off-by: Amit Pundir <amit.pun...@linaro.org>
---
 drivers/usb/gadget/function/f_fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index b6cf5ab5a0a1..f9bd351637cd 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3700,7 +3700,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();
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to