[PATCH] USB: Make otg_state_string generic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Felipe Balbi <felipe.souza-lima-de@xxxxxxxxx>

Instead of defining otg_state_string-like functions for each otg
transceiver driver, make otg_state_string generic and change its users.

Signed-off-by: Felipe Balbi <felipe.souza-lima-de@xxxxxxxxx>
---
 drivers/i2c/chips/isp1301_omap.c |   60 +++++++++++---------------------------
 drivers/usb/musb/musb_core.c     |   52 ++++++++++----------------------
 drivers/usb/musb/musb_debug.h    |    2 -
 drivers/usb/musb/musb_gadget.c   |    8 ++--
 drivers/usb/musb/musb_host.c     |    2 +-
 drivers/usb/musb/musb_virthub.c  |    4 +-
 drivers/usb/musb/tusb6010.c      |   14 ++++----
 include/linux/usb/otg.h          |   22 ++++++++++++++
 8 files changed, 69 insertions(+), 95 deletions(-)

diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index 5fb27cb..1efc9e7 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -233,31 +233,6 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits)
 
 /*-------------------------------------------------------------------------*/
 
-static const char *state_string(enum usb_otg_state state)
-{
-	switch (state) {
-	case OTG_STATE_A_IDLE:		return "a_idle";
-	case OTG_STATE_A_WAIT_VRISE:	return "a_wait_vrise";
-	case OTG_STATE_A_WAIT_BCON:	return "a_wait_bcon";
-	case OTG_STATE_A_HOST:		return "a_host";
-	case OTG_STATE_A_SUSPEND:	return "a_suspend";
-	case OTG_STATE_A_PERIPHERAL:	return "a_peripheral";
-	case OTG_STATE_A_WAIT_VFALL:	return "a_wait_vfall";
-	case OTG_STATE_A_VBUS_ERR:	return "a_vbus_err";
-	case OTG_STATE_B_IDLE:		return "b_idle";
-	case OTG_STATE_B_SRP_INIT:	return "b_srp_init";
-	case OTG_STATE_B_PERIPHERAL:	return "b_peripheral";
-	case OTG_STATE_B_WAIT_ACON:	return "b_wait_acon";
-	case OTG_STATE_B_HOST:		return "b_host";
-	default:			return "UNDEFINED";
-	}
-}
-
-static inline const char *state_name(struct isp1301 *isp)
-{
-	return state_string(isp->otg.state);
-}
-
 #ifdef	VERBOSE
 #define	dev_vdbg			dev_dbg
 #else
@@ -379,7 +354,7 @@ static void a_idle(struct isp1301 *isp, const char *tag)
 	}
 	isp->otg.state = OTG_STATE_A_IDLE;
 	isp->last_otg_ctrl = OTG_CTRL_REG = OTG_CTRL_REG & OTG_XCEIV_OUTPUTS;
-	pr_debug("  --> %s/%s\n", state_name(isp), tag);
+	pr_debug("  --> %s/%s\n", otg_state_string(&isp->otg), tag);
 }
 
 /* called from irq handlers */
@@ -399,7 +374,7 @@ static void b_idle(struct isp1301 *isp, const char *tag)
 	}
 	isp->otg.state = OTG_STATE_B_IDLE;
 	isp->last_otg_ctrl = OTG_CTRL_REG = OTG_CTRL_REG & OTG_XCEIV_OUTPUTS;
-	pr_debug("  --> %s/%s\n", state_name(isp), tag);
+	pr_debug("  --> %s/%s\n", otg_state_string(&isp->otg), tag);
 }
 
 static void
@@ -411,7 +386,7 @@ dump_regs(struct isp1301 *isp, const char *label)
 	u8	src = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE);
 
 	pr_debug("otg: %06x, %s %s, otg/%02x stat/%02x.%02x\n",
-		OTG_CTRL_REG, label, state_name(isp),
+		OTG_CTRL_REG, label, otg_state_string(&isp->otg),
 		ctrl, status, src);
 	/* mode control and irq enables don't change much */
 #endif
@@ -498,8 +473,8 @@ static void check_state(struct isp1301 *isp, const char *tag)
 	}
 	if (isp->otg.state == state && !extra)
 		return;
-	pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag,
-		state_string(state), fsm, state_name(isp), OTG_CTRL_REG);
+	pr_debug("otg: %s FSM %s/%02x, %06x\n", tag,
+		otg_state_string(&isp->otg), fsm, OTG_CTRL_REG);
 }
 
 #else
@@ -702,7 +677,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
 	/* HNP to become b_host failed */
 	} else if (otg_irq & B_HNP_FAIL) {
 		pr_debug("otg: %s B_HNP_FAIL, %06x\n",
-				state_name(isp), OTG_CTRL_REG);
+				otg_state_string(&isp->otg), OTG_CTRL_REG);
 		notresponding(isp);
 
 		otg_ctrl = OTG_CTRL_REG;
@@ -720,7 +695,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
 	/* detect SRP from B-device ... */
 	} else if (otg_irq & A_SRP_DETECT) {
 		pr_debug("otg: %s SRP_DETECT, %06x\n",
-				state_name(isp), OTG_CTRL_REG);
+				otg_state_string(&isp->otg), OTG_CTRL_REG);
 
 		isp1301_defer_work(isp, WORK_UPDATE_OTG);
 		switch (isp->otg.state) {
@@ -748,7 +723,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
 	} else if (otg_irq & A_REQ_TMROUT) {
 		otg_ctrl = OTG_CTRL_REG;
 		pr_info("otg: BCON_TMOUT from %s, %06x\n",
-				state_name(isp), otg_ctrl);
+				otg_state_string(&isp->otg), otg_ctrl);
 		notresponding(isp);
 
 		otg_ctrl |= OTG_BUSDROP;
@@ -763,7 +738,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
 	} else if (otg_irq & A_VBUS_ERR) {
 		otg_ctrl = OTG_CTRL_REG;
 		printk(KERN_ERR "otg: %s, VBUS_ERR %04x ctrl %06x\n",
-			state_name(isp), otg_irq, otg_ctrl);
+			otg_state_string(&isp->otg), otg_irq, otg_ctrl);
 
 		otg_ctrl |= OTG_BUSDROP;
 		otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS;
@@ -781,7 +756,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
 
 		otg_ctrl = OTG_CTRL_REG;
 		printk(KERN_NOTICE "otg: %s, SWITCH to %s, ctrl %06x\n",
-				state_name(isp),
+				otg_state_string(&isp->otg),
 				(otg_ctrl & OTG_DRIVER_SEL)
 					? "gadget" : "host",
 				otg_ctrl);
@@ -864,7 +839,7 @@ static int otg_init(struct isp1301 *isp)
 
 	check_state(isp, __FUNCTION__);
 	pr_debug("otg: %s, %s %06x\n",
-			state_name(isp), __FUNCTION__, OTG_CTRL_REG);
+			otg_state_string(&isp->otg), __FUNCTION__, OTG_CTRL_REG);
 
 	OTG_IRQ_EN_REG = DRIVER_SWITCH | OPRT_CHG
 			| B_SRP_TMROUT | B_HNP_FAIL
@@ -959,7 +934,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
 	enum usb_otg_state	state = isp->otg.state;
 
 	if (stat & INTR_BDIS_ACON)
-		pr_debug("OTG:  BDIS_ACON, %s\n", state_name(isp));
+		pr_debug("OTG:  BDIS_ACON, %s\n", otg_state_string(&isp->otg));
 
 	/* start certain state transitions right away */
 	isp_stat = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE);
@@ -1071,14 +1046,13 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
 			break;
 		default:
 			pr_debug("otg: unsupported b-device %s\n",
-				state_name(isp));
+				otg_state_string(&isp->otg));
 			break;
 		}
 	}
 
 	if (state != isp->otg.state)
-		pr_debug("  isp, %s -> %s\n",
-				state_string(state), state_name(isp));
+		pr_debug("  isp %s\n", otg_state_string(&isp->otg));
 
 #ifdef	CONFIG_USB_OTG
 	/* update the OTG controller state to match the isp1301; may
@@ -1155,7 +1129,7 @@ isp1301_work(struct work_struct *work)
 				break;
 			default:
 				pr_debug("  host resume in %s\n",
-						state_name(isp));
+						otg_state_string(&isp->otg));
 			}
 			host_resume(isp);
 			// mdelay(10);
@@ -1420,7 +1394,7 @@ isp1301_start_srp(struct otg_transceiver *dev)
 	OTG_CTRL_REG = otg_ctrl;
 	isp->otg.state = OTG_STATE_B_SRP_INIT;
 
-	pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), OTG_CTRL_REG);
+	pr_debug("otg: SRP, %s ... %06x\n", otg_state_string(&isp->otg), OTG_CTRL_REG);
 #ifdef	CONFIG_USB_OTG
 	check_state(isp, __FUNCTION__);
 #endif
@@ -1472,7 +1446,7 @@ isp1301_start_hnp(struct otg_transceiver *dev)
 		return -EILSEQ;
 	}
 	pr_debug("otg: HNP %s, %06x ...\n",
-		state_name(isp), OTG_CTRL_REG);
+		otg_state_string(&isp->otg), OTG_CTRL_REG);
 	check_state(isp, __FUNCTION__);
 	return 0;
 #else
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index cf29bde..b333767 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -272,26 +272,6 @@ void musb_load_testpacket(struct musb *musb)
 
 /*-------------------------------------------------------------------------*/
 
-const char *otg_state_string(struct musb *musb)
-{
-	switch (musb->xceiv.state) {
-	case OTG_STATE_A_IDLE:		return "a_idle";
-	case OTG_STATE_A_WAIT_VRISE:	return "a_wait_vrise";
-	case OTG_STATE_A_WAIT_BCON:	return "a_wait_bcon";
-	case OTG_STATE_A_HOST:		return "a_host";
-	case OTG_STATE_A_SUSPEND:	return "a_suspend";
-	case OTG_STATE_A_PERIPHERAL:	return "a_peripheral";
-	case OTG_STATE_A_WAIT_VFALL:	return "a_wait_vfall";
-	case OTG_STATE_A_VBUS_ERR:	return "a_vbus_err";
-	case OTG_STATE_B_IDLE:		return "b_idle";
-	case OTG_STATE_B_SRP_INIT:	return "b_srp_init";
-	case OTG_STATE_B_PERIPHERAL:	return "b_peripheral";
-	case OTG_STATE_B_WAIT_ACON:	return "b_wait_acon";
-	case OTG_STATE_B_HOST:		return "b_host";
-	default:			return "UNDEFINED";
-	}
-}
-
 #ifdef	CONFIG_USB_MUSB_OTG
 
 /*
@@ -321,7 +301,7 @@ void musb_otg_timer_func(unsigned long data)
 		musb_hnp_stop(musb);
 		break;
 	default:
-		DBG(1, "HNP: Unhandled mode %s\n", otg_state_string(musb));
+		DBG(1, "HNP: Unhandled mode %s\n", otg_state_string(&musb->xceiv));
 	}
 	musb->ignore_disconnect = 0;
 	spin_unlock_irqrestore(&musb->lock, flags);
@@ -360,7 +340,7 @@ void musb_hnp_stop(struct musb *musb)
 		break;
 	default:
 		DBG(1, "HNP: Stopping in unknown state %s\n",
-			otg_state_string(musb));
+			otg_state_string(&musb->xceiv));
 	}
 
 	/*
@@ -405,7 +385,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 	 */
 	if (int_usb & MUSB_INTR_RESUME) {
 		handled = IRQ_HANDLED;
-		DBG(3, "RESUME (%s)\n", otg_state_string(musb));
+		DBG(3, "RESUME (%s)\n", otg_state_string(&musb->xceiv));
 
 		if (devctl & MUSB_DEVCTL_HM) {
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
@@ -444,7 +424,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 			default:
 				WARN("bogus %s RESUME (%s)\n",
 					"host",
-					otg_state_string(musb));
+					otg_state_string(&musb->xceiv));
 			}
 #endif
 		} else {
@@ -478,7 +458,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 			default:
 				WARN("bogus %s RESUME (%s)\n",
 					"peripheral",
-					otg_state_string(musb));
+					otg_state_string(&musb->xceiv));
 			}
 		}
 	}
@@ -486,7 +466,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
 	/* see manual for the order of the tests */
 	if (int_usb & MUSB_INTR_SESSREQ) {
-		DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb));
+		DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(&musb->xceiv));
 
 		/* IRQ arrives from ID pin sense or (later, if VBUS power
 		 * is removed) SRP.  responses are time critical:
@@ -549,7 +529,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 		}
 
 		DBG(1, "VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
-				otg_state_string(musb),
+				otg_state_string(&musb->xceiv),
 				devctl,
 				({ char *s;
 				switch (devctl & MUSB_DEVCTL_VBUS) {
@@ -633,7 +613,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 			break;
 		}
 		DBG(1, "CONNECT (%s) devctl %02x\n",
-				otg_state_string(musb), devctl);
+				otg_state_string(&musb->xceiv), devctl);
 	}
 #endif	/* CONFIG_USB_MUSB_HDRC_HCD */
 
@@ -656,7 +636,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 				musb_writeb(mbase, MUSB_DEVCTL, 0);
 			}
 		} else if (is_peripheral_capable()) {
-			DBG(1, "BUS RESET as %s\n", otg_state_string(musb));
+			DBG(1, "BUS RESET as %s\n", otg_state_string(&musb->xceiv));
 			switch (musb->xceiv.state) {
 #ifdef CONFIG_USB_OTG
 			case OTG_STATE_A_SUSPEND:
@@ -665,7 +645,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 				/* FALLTHROUGH */
 			case OTG_STATE_A_WAIT_BCON:	/* OPT TD.4.7-900ms */
 				DBG(1, "HNP: Setting timer as %s\n",
-						otg_state_string(musb));
+						otg_state_string(&musb->xceiv));
 				musb_otg_timer.data = (unsigned long)musb;
 				mod_timer(&musb_otg_timer, jiffies
 					+ msecs_to_jiffies(100));
@@ -675,7 +655,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 				break;
 			case OTG_STATE_B_WAIT_ACON:
 				DBG(1, "HNP: RESET (%s), back to b_peripheral\n",
-					otg_state_string(musb));
+					otg_state_string(&musb->xceiv));
 				musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
 				musb_g_reset(musb);
 				break;
@@ -688,7 +668,7 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 				break;
 			default:
 				DBG(1, "Unhandled BUS RESET as %s\n",
-					otg_state_string(musb));
+					otg_state_string(&musb->xceiv));
 			}
 		}
 
@@ -762,7 +742,7 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb,
 
 	if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) {
 		DBG(1, "DISCONNECT (%s) as %s, devctl %02x\n",
-				otg_state_string(musb),
+				otg_state_string(&musb->xceiv),
 				MUSB_MODE(musb), devctl);
 		handled = IRQ_HANDLED;
 
@@ -795,7 +775,7 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb,
 #endif	/* GADGET */
 		default:
 			WARN("unhandled DISCONNECT transition (%s)\n",
-				otg_state_string(musb));
+				otg_state_string(&musb->xceiv));
 			break;
 		}
 
@@ -804,7 +784,7 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb,
 
 	if (int_usb & MUSB_INTR_SUSPEND) {
 		DBG(1, "SUSPEND (%s) devctl %02x power %02x\n",
-				otg_state_string(musb), devctl, power);
+				otg_state_string(&musb->xceiv), devctl, power);
 		handled = IRQ_HANDLED;
 
 		switch (musb->xceiv.state) {
@@ -1672,7 +1652,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
 	int ret = -EINVAL;
 
 	spin_lock_irqsave(&musb->lock, flags);
-	ret = sprintf(buf, "%s\n", otg_state_string(musb));
+	ret = sprintf(buf, "%s\n", otg_state_string(&musb->xceiv));
 	spin_unlock_irqrestore(&musb->lock, flags);
 
 	return ret;
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index a9a0055..02731c3 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -61,6 +61,4 @@ static inline int _dbg_level(unsigned l)
 
 #define DBG(level,fmt,args...) xprintk(level,KERN_DEBUG,fmt, ## args)
 
-extern const char *otg_state_string(struct musb *);
-
 #endif				/*  __MUSB_LINUX_DEBUG_H__ */
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 0fb9635..aa24a54 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1431,7 +1431,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
 		status = 0;
 		goto done;
 	default:
-		DBG(2, "Unhandled wake: %s\n", otg_state_string(musb));
+		DBG(2, "Unhandled wake: %s\n", otg_state_string(&musb->xceiv));
 		goto done;
 	}
 
@@ -1888,7 +1888,7 @@ void musb_g_resume(struct musb *musb)
 		break;
 	default:
 		WARN("unhandled RESUME transition (%s)\n",
-				otg_state_string(musb));
+				otg_state_string(&musb->xceiv));
 	}
 }
 
@@ -1918,7 +1918,7 @@ void musb_g_suspend(struct musb *musb)
 		 * A_PERIPHERAL may need care too
 		 */
 		WARN("unhandled SUSPEND transition (%s)\n",
-				otg_state_string(musb));
+				otg_state_string(&musb->xceiv));
 	}
 }
 
@@ -1953,7 +1953,7 @@ void musb_g_disconnect(struct musb *musb)
 	default:
 #ifdef	CONFIG_USB_MUSB_OTG
 		DBG(2, "Unhandled disconnect %s, setting a_idle\n",
-			otg_state_string(musb));
+			otg_state_string(&musb->xceiv));
 		musb->xceiv.state = OTG_STATE_A_IDLE;
 		break;
 	case OTG_STATE_A_PERIPHERAL:
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 2ad2ed9..1042ff2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2122,7 +2122,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
 
 	if (is_host_active(musb) && musb->is_active) {
 		WARN("trying to suspend as %s is_active=%i\n",
-			otg_state_string(musb), musb->is_active);
+			otg_state_string(&musb->xceiv), musb->is_active);
 		return -EBUSY;
 	} else
 		return 0;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 10b9089..d8e4918 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -95,7 +95,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend)
 #endif
 		default:
 			DBG(1, "bogus rh suspend? %s\n",
-				otg_state_string(musb));
+				otg_state_string(&musb->xceiv));
 		}
 	} else if (power & MUSB_POWER_SUSPENDM) {
 		power &= ~MUSB_POWER_SUSPENDM;
@@ -196,7 +196,7 @@ void musb_root_disconnect(struct musb *musb)
 		musb->xceiv.state = OTG_STATE_B_IDLE;
 		break;
 	default:
-		DBG(1, "host disconnect (%s)\n", otg_state_string(musb));
+		DBG(1, "host disconnect (%s)\n", otg_state_string(&musb->xceiv));
 	}
 }
 
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 3008b6d..15b7382 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -426,7 +426,7 @@ static void musb_do_idle(unsigned long _musb)
 			&& (musb->idle_timeout == 0
 				|| time_after(jiffies, musb->idle_timeout))) {
 			DBG(4, "Nothing connected %s, turning off VBUS\n",
-					otg_state_string(musb));
+					otg_state_string(&musb->xceiv));
 		}
 		/* FALLTHROUGH */
 	case OTG_STATE_A_IDLE:
@@ -485,7 +485,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
 	/* Never idle if active, or when VBUS timeout is not set as host */
 	if (musb->is_active || ((musb->a_wait_bcon == 0)
 			&& (musb->xceiv.state == OTG_STATE_A_WAIT_BCON))) {
-		DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
+		DBG(4, "%s active, deleting timer\n", otg_state_string(&musb->xceiv));
 		del_timer(&musb_idle_timer);
 		last_timer = jiffies;
 		return;
@@ -502,7 +502,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
 	last_timer = timeout;
 
 	DBG(4, "%s inactive, for idle timer for %lu ms\n",
-		otg_state_string(musb),
+		otg_state_string(&musb->xceiv),
 		(unsigned long)jiffies_to_msecs(timeout - jiffies));
 	mod_timer(&musb_idle_timer, timeout);
 }
@@ -581,7 +581,7 @@ static void tusb_source_power(struct musb *musb, int is_on)
 	musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
 
 	DBG(1, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
-		otg_state_string(musb),
+		otg_state_string(&musb->xceiv),
 		musb_readb(musb->mregs, MUSB_DEVCTL),
 		musb_readl(tbase, TUSB_DEV_OTG_STAT),
 		conf, prcm);
@@ -707,13 +707,13 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
 				musb->is_active = 0;
 			}
 			DBG(2, "vbus change, %s, otg %03x\n",
-				otg_state_string(musb), otg_stat);
+				otg_state_string(&musb->xceiv), otg_stat);
 			idle_timeout = jiffies + (1 * HZ);
 			schedule_work(&musb->irq_work);
 
 		} else /* A-dev state machine */ {
 			DBG(2, "vbus change, %s, otg %03x\n",
-				otg_state_string(musb), otg_stat);
+				otg_state_string(&musb->xceiv), otg_stat);
 
 			switch (musb->xceiv.state) {
 			case OTG_STATE_A_IDLE:
@@ -761,7 +761,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
 	if (int_src & TUSB_INT_SRC_OTG_TIMEOUT) {
 		u8	devctl;
 
-		DBG(4, "%s timer, %03x\n", otg_state_string(musb), otg_stat);
+		DBG(4, "%s timer, %03x\n", otg_state_string(&musb->xceiv), otg_stat);
 
 		switch (musb->xceiv.state) {
 		case OTG_STATE_A_WAIT_VRISE:
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 79c36fc..96a2e0f 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -142,6 +142,28 @@ otg_start_srp(struct otg_transceiver *otg)
 	return otg->start_srp(otg);
 }
 
+/* pretty printing of otg states */
+static inline const char *
+otg_state_string(struct otg_transceiver *otg)
+{
+	switch (otg->state) {
+	case OTG_STATE_A_IDLE:		return "a_idle";
+	case OTG_STATE_A_WAIT_VRISE:	return "a_wait_vrise";
+	case OTG_STATE_A_WAIT_BCON:	return "a_wait_bcon";
+	case OTG_STATE_A_HOST:		return "a_host";
+	case OTG_STATE_A_SUSPEND:	return "a_suspend";
+	case OTG_STATE_A_PERIPHERAL:	return "a_peripheral";
+	case OTG_STATE_A_WAIT_VFALL:	return "a_wait_vfall";
+	case OTG_STATE_A_VBUS_ERR:	return "a_vbus_err";
+	case OTG_STATE_B_IDLE:		return "b_idle";
+	case OTG_STATE_B_SRP_INIT:	return "b_srp_init";
+	case OTG_STATE_B_PERIPHERAL:	return "b_peripheral";
+	case OTG_STATE_B_WAIT_ACON:	return "b_wait_acon";
+	case OTG_STATE_B_HOST:		return "b_host";
+	default:			return "UNDEFINED";
+	}
+}
+
 
 /* for OTG controller drivers (and maybe other stuff) */
 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
-- 
1.5.4.rc5

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

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux