MLK-10750 usb: chipidea: otg: remove otg fsm before destory gdaget and host
authorLi Jun <jun.li@freescale.com>
Tue, 28 Apr 2015 11:56:35 +0000 (19:56 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:05 +0000 (14:47 -0500)
If unload ci_hdrc driver while otg fsm is running as A-device, we should
firstly clean otg fsm and stop all otg fsm timers before destroy gadget
and host.

Signed-off-by: Li Jun <jun.li@freescale.com>
(cherry picked from commit 95b62fe02aee5d2a83a9eb60816ee7cfc16708e8)

drivers/usb/chipidea/core.c
drivers/usb/chipidea/otg_fsm.c

index 3c7831d..3443d9b 100644 (file)
@@ -864,10 +864,10 @@ EXPORT_SYMBOL_GPL(ci_hdrc_query_available_role);
 
 static inline void ci_role_destroy(struct ci_hdrc *ci)
 {
-       ci_hdrc_gadget_destroy(ci);
-       ci_hdrc_host_destroy(ci);
        if (ci->is_otg)
                ci_hdrc_otg_destroy(ci);
+       ci_hdrc_gadget_destroy(ci);
+       ci_hdrc_host_destroy(ci);
 }
 
 static void ci_get_otg_capable(struct ci_hdrc *ci)
index 63701d1..e8486d5 100644 (file)
@@ -865,6 +865,13 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
 
 void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
 {
+       enum otg_fsm_timer i;
+
+       for (i = 0; i < NUM_OTG_FSM_TIMERS; i++)
+               otg_del_timer(&ci->fsm, i);
+
+       ci->enabled_otg_timer_bits = 0;
+
        /* Turn off vbus if vbus is on */
        if (ci->fsm.a_vbus_vld)
                otg_drv_vbus(&ci->fsm, 0);