USB: dwc3_otg: Always schedule OTG state-machine for any ext events

Commit: b7434561, "USB: dwc3: Add support for basic OTG in superspeed
mode" introduced regression by not putting hardware in LPM on bootup
without USB cable connected.
During boot-up external transceiver driver may notify initial BSV
and ID events to OTG driver even if they are not changed. Since,
ext_xceiv driver brings hardware out of LPM before notifying
events to OTG, hence, schedule state-machine which then takes care
of putting hardware in LPM accordingly.

CRs-Fixed: 433384
Change-Id: I1e74bc2b1febb6dd91293aad9e3690bd2c2eaed2
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/dwc3/dwc3_otg.c b/drivers/usb/dwc3/dwc3_otg.c
index 136cc5d..361aa32 100644
--- a/drivers/usb/dwc3/dwc3_otg.c
+++ b/drivers/usb/dwc3/dwc3_otg.c
@@ -337,7 +337,6 @@
 	struct dwc3_ext_xceiv *ext_xceiv = dotg->ext_xceiv;
 	struct usb_phy *phy = dotg->otg.phy;
 	int ret = 0;
-	int work = 0;
 
 	if (event == DWC3_EVENT_PHY_RESUME) {
 		if (!pm_runtime_status_suspended(phy->dev)) {
@@ -358,27 +357,19 @@
 		}
 	} else if (event == DWC3_EVENT_XCEIV_STATE) {
 		if (ext_xceiv->id == DWC3_ID_FLOAT) {
-			if (!test_and_set_bit(ID, &dotg->inputs)) {
-				dev_dbg(phy->dev, "XCVR: ID set\n");
-				work = 1;
-			}
+			dev_dbg(phy->dev, "XCVR: ID set\n");
+			set_bit(ID, &dotg->inputs);
 		} else {
-			if (test_and_clear_bit(ID, &dotg->inputs)) {
-				dev_dbg(phy->dev, "XCVR: ID clear\n");
-				work = 1;
-			}
+			dev_dbg(phy->dev, "XCVR: ID clear\n");
+			clear_bit(ID, &dotg->inputs);
 		}
 
 		if (ext_xceiv->bsv) {
-			if (!test_and_set_bit(B_SESS_VLD, &dotg->inputs)) {
-				dev_dbg(phy->dev, "XCVR: BSV set\n");
-				work = 1;
-			}
+			dev_dbg(phy->dev, "XCVR: BSV set\n");
+			set_bit(B_SESS_VLD, &dotg->inputs);
 		} else {
-			if (test_and_clear_bit(B_SESS_VLD, &dotg->inputs)) {
-				dev_dbg(phy->dev, "XCVR: BSV clear\n");
-				work = 1;
-			}
+			dev_dbg(phy->dev, "XCVR: BSV clear\n");
+			clear_bit(B_SESS_VLD, &dotg->inputs);
 		}
 
 		if (!init) {
@@ -387,8 +378,8 @@
 			dev_dbg(phy->dev, "XCVR: BSV init complete\n");
 			return;
 		}
-		if (work)
-			schedule_work(&dotg->sm_work);
+
+		schedule_work(&dotg->sm_work);
 	}
 }
 
@@ -714,7 +705,8 @@
 			phy->state = OTG_STATE_B_IDLE;
 			work = 1;
 		} else {
-			 if (dwc3_otg_start_host(&dotg->otg, 1)) {
+			phy->state = OTG_STATE_A_HOST;
+			if (dwc3_otg_start_host(&dotg->otg, 1)) {
 				/*
 				 * Probably set_host was not called yet.
 				 * We will re-try as soon as it will be called
@@ -725,7 +717,6 @@
 				pm_runtime_put_sync(phy->dev);
 				return;
 			}
-			phy->state = OTG_STATE_A_HOST;
 		}
 		break;