summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHemant Kumar <hemantk@codeaurora.org>2018-01-09 12:30:53 +0530
committerDongwoo Lee <dwoo08.lee@samsung.com>2019-11-26 11:22:25 +0900
commit8456de9c37805264becc5489af0f8c85a184adfa (patch)
tree3059dc50d05948f7484b7e7f764f142479f3b046
parenta7276b9da72d9f8d3783e64a93af97840b617051 (diff)
downloadlinux-4.9-exynos9110-8456de9c37805264becc5489af0f8c85a184adfa.tar.gz
linux-4.9-exynos9110-8456de9c37805264becc5489af0f8c85a184adfa.tar.bz2
linux-4.9-exynos9110-8456de9c37805264becc5489af0f8c85a184adfa.zip
usb: f_fs: Prevent gadget unbind if it is already unbound
commit ce5bf9a50daf2d9078b505aca1cea22e88ecb94a upstream. 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 <balbi@kernel.org> Cc: Greg KH <gregkh@linux-foundation.org> Cc: Michal Nazarewicz <mina86@mina86.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Dmitry Shmidt <dimitrysh@google.com> Cc: Badhri <badhri@google.com> Cc: Android Kernel Team <kernel-team@android.com> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org> [AmitP: Cherry-picked it from android-4.14 and updated the commit log] Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [dwoo08.lee: cherry-pick linux-4.9.y stable commit f24d171a8100 to stablize f_fs] Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com> Change-Id: Ifbab9f182fa3779c57ab288958553c3711d50e28
-rw-r--r--drivers/usb/gadget/function/f_fs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 46c6123c0e8a..59ad9c34b0af 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3736,7 +3736,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();