Commit a3cc6af4 authored by Li Jun's avatar Li Jun Committed by Luis Henriques

usb: chipidea: otg: remove mutex unlock and lock while stop and start role

commit a5a356ce upstream.

Wrongly release mutex lock during otg_statemachine may result in re-enter
otg_statemachine, which is not allowed, we should do next state transtition
after previous one completed.

Fixes: 826cfe75 ("usb: chipidea: add OTG fsm operation functions implementation")
Signed-off-by: default avatarLi Jun <jun.li@freescale.com>
Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent a3a4d316
...@@ -537,7 +537,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on) ...@@ -537,7 +537,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
{ {
struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm); struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
mutex_unlock(&fsm->lock);
if (on) { if (on) {
ci_role_stop(ci); ci_role_stop(ci);
ci_role_start(ci, CI_ROLE_HOST); ci_role_start(ci, CI_ROLE_HOST);
...@@ -546,7 +545,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on) ...@@ -546,7 +545,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
hw_device_reset(ci, USBMODE_CM_DC); hw_device_reset(ci, USBMODE_CM_DC);
ci_role_start(ci, CI_ROLE_GADGET); ci_role_start(ci, CI_ROLE_GADGET);
} }
mutex_lock(&fsm->lock);
return 0; return 0;
} }
...@@ -554,12 +552,10 @@ static int ci_otg_start_gadget(struct otg_fsm *fsm, int on) ...@@ -554,12 +552,10 @@ static int ci_otg_start_gadget(struct otg_fsm *fsm, int on)
{ {
struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm); struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
mutex_unlock(&fsm->lock);
if (on) if (on)
usb_gadget_vbus_connect(&ci->gadget); usb_gadget_vbus_connect(&ci->gadget);
else else
usb_gadget_vbus_disconnect(&ci->gadget); usb_gadget_vbus_disconnect(&ci->gadget);
mutex_lock(&fsm->lock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment