[PATCH 02/25] USB OTG Langwell: Clean code and use dev_dbg for debug.

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

 



From: Hao Wu <hao.wu@xxxxxxxxx>

This patch is only for code clean and no change any logic in driver code.

Main change
- Fix coding style issue found by checkpatch
- Remove otg_dbg and use dev_dbg instead
- Short variable name

Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
Signed-off-by: Alan Cox <alan@xxxxxxxxxxxxxxx>
---

 drivers/usb/otg/langwell_otg.c   | 1298 ++++++++++++++++++++------------------
 include/linux/usb/langwell_otg.h |   21 -
 2 files changed, 692 insertions(+), 627 deletions(-)


diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
index fff3fcc..ada4cda 100644
--- a/drivers/usb/otg/langwell_otg.c
+++ b/drivers/usb/otg/langwell_otg.c
@@ -139,8 +139,11 @@ static struct langwell_otg *the_transceiver;
 /* host/client notify transceiver when event affects HNP state */
 void langwell_update_transceiver()
 {
-	otg_dbg("transceiver driver is notified\n");
-	queue_work(the_transceiver->qwork, &the_transceiver->work);
+	struct langwell_otg *lnw = the_transceiver;
+
+	dev_dbg(&lnw->pdev->dev, "transceiver is updated\n");
+
+	queue_work(lnw->qwork, &lnw->work);
 }
 EXPORT_SYMBOL(langwell_update_transceiver);
 
@@ -169,45 +172,48 @@ static int langwell_otg_set_power(struct otg_transceiver *otg,
 /* A-device drives vbus, controlled through PMIC CHRGCNTL register*/
 static void langwell_otg_drv_vbus(int on)
 {
+	struct langwell_otg		*lnw = the_transceiver;
 	u8 r;
-	
+
+	dev_dbg(&lnw->pdev->dev, "%s <--- %s\n", __func__, on ? "on" : "off");
+
 	/* FIXME: surely we should cache this on the first read. If not use
 	   readv to avoid two transactions */
 	if (intel_scu_ipc_ioread8(0x00, &r) < 0) {
-		otg_dbg("Failed to read PMIC register 0xD2");
+		dev_dbg(&lnw->pdev->dev, "Failed to read PMIC register 0xD2");
 		return;
 	}
 	if ((r & 0x03) != 0x02) {
-		otg_dbg("not NEC PMIC attached\n");
+		dev_dbg(&lnw->pdev->dev, "not NEC PMIC attached\n");
 		return;
 	}
 
 	if (intel_scu_ipc_ioread8(0x20, &r) < 0) {
-		otg_dbg("Failed to read PMIC register 0xD2");
+		dev_dbg(&lnw->pdev->dev, "Failed to read PMIC register 0xD2");
 		return;
 	}
-	
 
 	if ((r & 0x20) == 0) {
-		otg_dbg("no battery attached\n");
+		dev_dbg(&lnw->pdev->dev, "no battery attached\n");
 		return;
 	}
 
 	/* Workaround for battery attachment issue */
 	if (r == 0x34) {
-		otg_dbg("no battery attached on SH \n");
+		dev_dbg(&lnw->pdev->dev, "no battery attached on SH\n");
 		return;
 	}
 
-	otg_dbg("battery attached. 2 reg = %x\n", r);
+	dev_dbg(&lnw->pdev->dev, "battery attached. 2 reg = %x\n", r);
 
 	/* workaround: FW detect writing 0x20/0xc0 to d4 event.
 	 * this is only for NEC PMIC.
 	 */
-	
+
 	if (intel_scu_ipc_iowrite8(0xD4, on ? 0x20 : 0xC0))
-		otg_dbg("Failed to write PMIC.\n");
+		dev_dbg(&lnw->pdev->dev, "Failed to write PMIC.\n");
 
+	dev_dbg(&lnw->pdev->dev, "%s --->\n", __func__);
 }
 
 /* charge vbus or discharge vbus through a resistor to ground */
@@ -230,37 +236,38 @@ static void langwell_otg_chrg_vbus(int on)
 /* Start SRP */
 static int langwell_otg_start_srp(struct otg_transceiver *otg)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	u32	val;
 
-	otg_dbg("Start SRP ->\n");
+	dev_dbg(&lnw->pdev->dev, "%s --->\n", __func__);
 
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
 
-	writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP,
-		the_transceiver->regs + CI_OTGSC);
+	writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP, lnw->regs + CI_OTGSC);
 
 	/* Check if the data plus is finished or not */
 	msleep(8);
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
 	if (val & (OTGSC_HADP | OTGSC_DP))
-		otg_dbg("DataLine SRP Error\n");
+		dev_dbg(&lnw->pdev->dev, "DataLine SRP Error\n");
 
 	/* Disable interrupt - b_sess_vld */
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
 	val &= (~(OTGSC_BSVIE | OTGSC_BSEIE));
-	writel(val, the_transceiver->regs + CI_OTGSC);
+	writel(val, lnw->regs + CI_OTGSC);
 
-	/* Start VBus SRP */
+	/* Start VBus SRP, drive vbus to generate VBus pulse */
 	langwell_otg_drv_vbus(1);
 	msleep(15);
 	langwell_otg_drv_vbus(0);
 
 	/* Enable interrupt - b_sess_vld*/
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
+	dev_dbg(&lnw->pdev->dev, "After VBUS pulse OTGSC = %x\n", val);
 	val |= (OTGSC_BSVIE | OTGSC_BSEIE);
-	writel(val, the_transceiver->regs + CI_OTGSC);
+	writel(val, lnw->regs + CI_OTGSC);
 
-	otg_dbg("Start SRP <-\n");
+	dev_dbg(&lnw->pdev->dev, "%s <---\n", __func__);
 	return 0;
 }
 
@@ -268,104 +275,120 @@ static int langwell_otg_start_srp(struct otg_transceiver *otg)
 /* stop SOF via bus_suspend */
 static void langwell_otg_loc_sof(int on)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	struct usb_hcd	*hcd;
 	int		err;
 
-	otg_dbg("loc_sof -> %d\n", on);
+	dev_dbg(&lnw->pdev->dev,
+			"%s ---> %s\n", __func__, on ? "suspend" : "resume");
 
-	hcd = bus_to_hcd(the_transceiver->otg.host);
+	hcd = bus_to_hcd(lnw->otg.host);
 	if (on)
 		err = hcd->driver->bus_resume(hcd);
 	else
 		err = hcd->driver->bus_suspend(hcd);
 
 	if (err)
-		otg_dbg("Failed to resume/suspend bus - %d\n", err);
+		dev_dbg(&lnw->pdev->dev,
+			"Fail to resume/suspend USB bus - %d\n", err);
+
+	dev_dbg(&lnw->pdev->dev, "%s <---\n", __func__);
 }
 
 static void langwell_otg_phy_low_power(int on)
 {
-	u8	val;
-	u8	phcd;
+	struct langwell_otg	*lnw = the_transceiver;
+	u8			val, phcd;
 
-	otg_dbg("phy low power mode-> %d\n", on);
+	dev_dbg(&lnw->pdev->dev, "%s ---> %s mode\n",
+			__func__, on ? "Low power" : "Normal");
 
 	phcd = 0x40;
 
-	val = readb(the_transceiver->regs + CI_HOSTPC1 + 2);
+	val = readb(lnw->regs + CI_HOSTPC1 + 2);
 
 	if (on)
-		writeb(val | phcd, the_transceiver->regs + CI_HOSTPC1 + 2);
+		writeb(val | phcd, lnw->regs + CI_HOSTPC1 + 2);
 	else
-		writeb(val & ~phcd, the_transceiver->regs + CI_HOSTPC1 + 2);
+		writeb(val & ~phcd, lnw->regs + CI_HOSTPC1 + 2);
+
+	dev_dbg(&lnw->pdev->dev, "%s <--- done\n", __func__);
 }
 
 /* Enable/Disable OTG interrupt */
 static void langwell_otg_intr(int on)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	u32 val;
 
-	otg_dbg("interrupt -> %d\n", on);
+	dev_dbg(&lnw->pdev->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
 
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
 	if (on) {
 		val = val | (OTGSC_INTEN_MASK);
-		writel(val, the_transceiver->regs + CI_OTGSC);
+		writel(val, lnw->regs + CI_OTGSC);
 	} else {
 		val = val & ~(OTGSC_INTEN_MASK);
-		writel(val, the_transceiver->regs + CI_OTGSC);
+		writel(val, lnw->regs + CI_OTGSC);
 	}
+	dev_dbg(&lnw->pdev->dev, "%s <---\n", __func__);
 }
 
 /* set HAAR: Hardware Assist Auto-Reset */
 static void langwell_otg_HAAR(int on)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	u32	val;
 
-	otg_dbg("HAAR -> %d\n", on);
+	dev_dbg(&lnw->pdev->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
 
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
 	if (on)
 		writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR,
-				the_transceiver->regs + CI_OTGSC);
+				lnw->regs + CI_OTGSC);
 	else
 		writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR,
-				the_transceiver->regs + CI_OTGSC);
+				lnw->regs + CI_OTGSC);
+
+	dev_dbg(&lnw->pdev->dev, "%s <---\n", __func__);
 }
 
 /* set HABA: Hardware Assist B-Disconnect to A-Connect */
 static void langwell_otg_HABA(int on)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	u32	val;
 
-	otg_dbg("HABA -> %d\n", on);
+	dev_dbg(&lnw->pdev->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
 
-	val = readl(the_transceiver->regs + CI_OTGSC);
+	val = readl(lnw->regs + CI_OTGSC);
 	if (on)
 		writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA,
-				the_transceiver->regs + CI_OTGSC);
+				lnw->regs + CI_OTGSC);
 	else
 		writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA,
-				the_transceiver->regs + CI_OTGSC);
+				lnw->regs + CI_OTGSC);
+
+	dev_dbg(&lnw->pdev->dev, "%s <---\n", __func__);
 }
 
 static int langwell_otg_check_se0_srp(int on)
 {
-	u32 val;
+	struct langwell_otg	*lnw = the_transceiver;
+	int			delay_time = TB_SE0_SRP * 10;
+	u32			val;
 
-	int delay_time = TB_SE0_SRP * 10; /* step is 100us */
-
-	otg_dbg("check_se0_srp -> \n");
+	dev_dbg(&lnw->pdev->dev, "%s --->\n", __func__);
 
 	do {
 		udelay(100);
 		if (!delay_time--)
 			break;
-		val = readl(the_transceiver->regs + CI_PORTSC1);
+		val = readl(lnw->regs + CI_PORTSC1);
 		val &= PORTSC_LS;
 	} while (!val);
 
-	otg_dbg("check_se0_srp <- \n");
+	dev_dbg(&lnw->pdev->dev, "%s <---\n", __func__);
 	return val;
 }
 
@@ -377,20 +400,22 @@ static void set_tmout(unsigned long indicator)
 
 void langwell_otg_nsf_msg(unsigned long indicator)
 {
+	struct langwell_otg	*lnw = the_transceiver;
+
 	switch (indicator) {
 	case 2:
 	case 4:
 	case 6:
 	case 7:
-		printk(KERN_ERR "OTG:NSF-%lu - deivce not responding\n",
-				indicator);
+		dev_warn(&lnw->pdev->dev,
+			"OTG:NSF-%lu - deivce not responding\n", indicator);
 		break;
 	case 3:
-		printk(KERN_ERR "OTG:NSF-%lu - deivce not supported\n",
-				indicator);
+		dev_warn(&lnw->pdev->dev,
+			"OTG:NSF-%lu - deivce not supported\n", indicator);
 		break;
 	default:
-		printk(KERN_ERR "Do not have this kind of NSF\n");
+		dev_warn(&lnw->pdev->dev, "Do not have this kind of NSF\n");
 		break;
 	}
 }
@@ -472,6 +497,7 @@ static void langwell_otg_del_timer(void *gtimer)
 /* Reduce timer count by 1, and find timeout conditions.*/
 static int langwell_otg_tick_timer(u32 *int_sts)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	struct langwell_otg_timer *tmp_timer, *del_tmp;
 	int expired = 0;
 
@@ -486,7 +512,7 @@ static int langwell_otg_tick_timer(u32 *int_sts)
 	}
 
 	if (list_empty(&active_timers)) {
-		otg_dbg("tick timer: disable 1ms int\n");
+		dev_dbg(&lnw->pdev->dev, "tick timer: disable 1ms int\n");
 		*int_sts = *int_sts & ~OTGSC_1MSE;
 	}
 	return expired;
@@ -494,25 +520,26 @@ static int langwell_otg_tick_timer(u32 *int_sts)
 
 static void reset_otg(void)
 {
-	u32	val;
-	int	delay_time = 1000;
+	struct langwell_otg	*lnw = the_transceiver;
+	int			delay_time = 1000;
+	u32			val;
 
-	otg_dbg("reseting OTG controller ...\n");
-	val = readl(the_transceiver->regs + CI_USBCMD);
-	writel(val | USBCMD_RST, the_transceiver->regs + CI_USBCMD);
+	dev_dbg(&lnw->pdev->dev, "reseting OTG controller ...\n");
+	val = readl(lnw->regs + CI_USBCMD);
+	writel(val | USBCMD_RST, lnw->regs + CI_USBCMD);
 	do {
 		udelay(100);
 		if (!delay_time--)
-			otg_dbg("reset timeout\n");
-		val = readl(the_transceiver->regs + CI_USBCMD);
+			dev_dbg(&lnw->pdev->dev, "reset timeout\n");
+		val = readl(lnw->regs + CI_USBCMD);
 		val &= USBCMD_RST;
 	} while (val != 0);
-	otg_dbg("reset done.\n");
+	dev_dbg(&lnw->pdev->dev, "reset done.\n");
 }
 
 static void set_host_mode(void)
 {
-	u32 	val;
+	u32	val;
 
 	reset_otg();
 	val = readl(the_transceiver->regs + CI_USBMODE);
@@ -522,7 +549,7 @@ static void set_host_mode(void)
 
 static void set_client_mode(void)
 {
-	u32 	val;
+	u32	val;
 
 	reset_otg();
 	val = readl(the_transceiver->regs + CI_USBMODE);
@@ -532,61 +559,61 @@ static void set_client_mode(void)
 
 static void init_hsm(void)
 {
-	struct langwell_otg	*langwell = the_transceiver;
+	struct langwell_otg	*lnw = the_transceiver;
 	u32			val32;
 
 	/* read OTGSC after reset */
-	val32 = readl(langwell->regs + CI_OTGSC);
-	otg_dbg("%s: OTGSC init value = 0x%x\n", __func__, val32);
+	val32 = readl(lnw->regs + CI_OTGSC);
+
+	dev_dbg(&lnw->pdev->dev, "%s: OTGSC value = 0x%x\n", __func__, val32);
 
 	/* set init state */
 	if (val32 & OTGSC_ID) {
-		langwell->hsm.id = 1;
-		langwell->otg.default_a = 0;
+		lnw->hsm.id = 1;
+		lnw->otg.default_a = 0;
 		set_client_mode();
-		langwell->otg.state = OTG_STATE_B_IDLE;
+		lnw->otg.state = OTG_STATE_B_IDLE;
 		langwell_otg_drv_vbus(0);
 	} else {
-		langwell->hsm.id = 0;
-		langwell->otg.default_a = 1;
+		lnw->hsm.id = 0;
+		lnw->otg.default_a = 1;
 		set_host_mode();
-		langwell->otg.state = OTG_STATE_A_IDLE;
+		lnw->otg.state = OTG_STATE_A_IDLE;
 	}
 
 	/* set session indicator */
 	if (val32 & OTGSC_BSE)
-		langwell->hsm.b_sess_end = 1;
+		lnw->hsm.b_sess_end = 1;
 	if (val32 & OTGSC_BSV)
-		langwell->hsm.b_sess_vld = 1;
+		lnw->hsm.b_sess_vld = 1;
 	if (val32 & OTGSC_ASV)
-		langwell->hsm.a_sess_vld = 1;
+		lnw->hsm.a_sess_vld = 1;
 	if (val32 & OTGSC_AVV)
-		langwell->hsm.a_vbus_vld = 1;
+		lnw->hsm.a_vbus_vld = 1;
 
 	/* defautly power the bus */
-	langwell->hsm.a_bus_req = 1;
-	langwell->hsm.a_bus_drop = 0;
+	lnw->hsm.a_bus_req = 1;
+	lnw->hsm.a_bus_drop = 0;
 	/* defautly don't request bus as B device */
-	langwell->hsm.b_bus_req = 0;
+	lnw->hsm.b_bus_req = 0;
 	/* no system error */
-	langwell->hsm.a_clr_err = 0;
+	lnw->hsm.a_clr_err = 0;
 }
 
 static void update_hsm(void)
 {
-	struct langwell_otg	*langwell = the_transceiver;
+	struct langwell_otg	*lnw = the_transceiver;
 	u32			val32;
 
 	/* read OTGSC */
-	val32 = readl(langwell->regs + CI_OTGSC);
-	otg_dbg("%s: OTGSC current value = 0x%x\n", __func__, val32);
-
-	langwell->hsm.id = !!(val32 & OTGSC_ID);
-	langwell->hsm.b_sess_end = !!(val32 & OTGSC_BSE);
-	langwell->hsm.b_sess_vld = !!(val32 & OTGSC_BSV);
-	langwell->hsm.a_sess_vld = !!(val32 & OTGSC_ASV);
-	langwell->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV);
-
+	val32 = readl(lnw->regs + CI_OTGSC);
+	dev_dbg(&lnw->pdev->dev, "%s: OTGSC value = 0x%x\n", __func__, val32);
+
+	lnw->hsm.id = !!(val32 & OTGSC_ID);
+	lnw->hsm.b_sess_end = !!(val32 & OTGSC_BSE);
+	lnw->hsm.b_sess_vld = !!(val32 & OTGSC_BSV);
+	lnw->hsm.a_sess_vld = !!(val32 & OTGSC_ASV);
+	lnw->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV);
 }
 
 static irqreturn_t otg_dummy_irq(int irq, void *_dev)
@@ -623,45 +650,56 @@ static irqreturn_t otg_dummy_irq(int irq, void *_dev)
 
 static irqreturn_t otg_irq(int irq, void *_dev)
 {
-	struct	langwell_otg *langwell = _dev;
+	struct	langwell_otg *lnw = _dev;
 	u32	int_sts, int_en;
 	u32	int_mask = 0;
 	int	flag = 0;
 
-	int_sts = readl(langwell->regs + CI_OTGSC);
+	int_sts = readl(lnw->regs + CI_OTGSC);
 	int_en = (int_sts & OTGSC_INTEN_MASK) >> 8;
 	int_mask = int_sts & int_en;
 	if (int_mask == 0)
 		return IRQ_NONE;
 
 	if (int_mask & OTGSC_IDIS) {
-		otg_dbg("%s: id change int\n", __func__);
-		langwell->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "%s: id change int\n", __func__);
+		lnw->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "id = %d\n", lnw->hsm.id);
 		flag = 1;
 	}
 	if (int_mask & OTGSC_DPIS) {
-		otg_dbg("%s: data pulse int\n", __func__);
-		langwell->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "%s: data pulse int\n", __func__);
+		lnw->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev,
+				"data pulse = %d\n", lnw->hsm.a_srp_det);
 		flag = 1;
 	}
 	if (int_mask & OTGSC_BSEIS) {
-		otg_dbg("%s: b session end int\n", __func__);
-		langwell->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "%s: b session end int\n", __func__);
+		lnw->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev,
+				"b_sess_end = %d\n", lnw->hsm.b_sess_end);
 		flag = 1;
 	}
 	if (int_mask & OTGSC_BSVIS) {
-		otg_dbg("%s: b session valid int\n", __func__);
-		langwell->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "%s: b session valid int\n", __func__);
+		lnw->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev,
+				"b_sess_vld = %d\n", lnw->hsm.b_sess_end);
 		flag = 1;
 	}
 	if (int_mask & OTGSC_ASVIS) {
-		otg_dbg("%s: a session valid int\n", __func__);
-		langwell->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "%s: a session valid int\n", __func__);
+		lnw->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev,
+				"a_sess_vld = %d\n", lnw->hsm.a_sess_vld);
 		flag = 1;
 	}
 	if (int_mask & OTGSC_AVVIS) {
-		otg_dbg("%s: a vbus valid int\n", __func__);
-		langwell->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev, "%s: a vbus valid int\n", __func__);
+		lnw->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
+		dev_dbg(&lnw->pdev->dev,
+				"a_vbus_vld = %d\n", lnw->hsm.a_vbus_vld);
 		flag = 1;
 	}
 
@@ -671,644 +709,679 @@ static irqreturn_t otg_irq(int irq, void *_dev)
 			flag = 1;
 	}
 
-	writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask,
-			langwell->regs + CI_OTGSC);
+	writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask, lnw->regs + CI_OTGSC);
 	if (flag)
-		queue_work(langwell->qwork, &langwell->work);
+		queue_work(lnw->qwork, &lnw->work);
 
 	return IRQ_HANDLED;
 }
 
 static void langwell_otg_work(struct work_struct *work)
 {
-	struct langwell_otg *langwell = container_of(work,
-					struct langwell_otg, work);
-	int	retval;
+	struct langwell_otg	*lnw;
+	int			retval;
 
-	otg_dbg("%s: old state = %s\n", __func__,
-			state_string(langwell->otg.state));
+	lnw = container_of(work, struct langwell_otg, work);
 
-	switch (langwell->otg.state) {
+	dev_dbg(&lnw->pdev->dev, "%s: old state = %s\n", __func__,
+			state_string(lnw->otg.state));
+
+	switch (lnw->otg.state) {
 	case OTG_STATE_UNDEFINED:
 	case OTG_STATE_B_IDLE:
-		if (!langwell->hsm.id) {
+		if (!lnw->hsm.id) {
 			langwell_otg_del_timer(b_srp_res_tmr);
-			langwell->otg.default_a = 1;
-			langwell->hsm.a_srp_det = 0;
+			lnw->otg.default_a = 1;
+			lnw->hsm.a_srp_det = 0;
 			langwell_otg_chrg_vbus(0);
 			langwell_otg_drv_vbus(0);
 			set_host_mode();
-			langwell->otg.state = OTG_STATE_A_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.b_srp_res_tmout) {
-			langwell->hsm.b_srp_res_tmout = 0;
-			langwell->hsm.b_bus_req = 0;
+			lnw->otg.state = OTG_STATE_A_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.b_srp_res_tmout) {
+			lnw->hsm.b_srp_res_tmout = 0;
+			lnw->hsm.b_bus_req = 0;
 			langwell_otg_nsf_msg(6);
-		} else if (langwell->hsm.b_sess_vld) {
+		} else if (lnw->hsm.b_sess_vld) {
 			langwell_otg_del_timer(b_srp_res_tmr);
-			langwell->hsm.b_sess_end = 0;
-			langwell->hsm.a_bus_suspend = 0;
+			lnw->hsm.b_sess_end = 0;
+			lnw->hsm.a_bus_suspend = 0;
 			langwell_otg_chrg_vbus(0);
-			if (langwell->client_ops) {
-				langwell->client_ops->resume(langwell->pdev);
-				langwell->otg.state = OTG_STATE_B_PERIPHERAL;
+			if (lnw->client_ops) {
+				lnw->client_ops->resume(lnw->pdev);
+				lnw->otg.state = OTG_STATE_B_PERIPHERAL;
 			} else
-				otg_dbg("client driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver not loaded.\n");
 
-		} else if (langwell->hsm.b_bus_req &&
-				(langwell->hsm.b_sess_end)) {
+		} else if (lnw->hsm.b_bus_req &&
+				(lnw->hsm.b_sess_end)) {
 			/* workaround for b_se0_srp detection */
 			retval = langwell_otg_check_se0_srp(0);
 			if (retval) {
-				langwell->hsm.b_bus_req = 0;
-				otg_dbg("LS is not SE0, try again later\n");
+				lnw->hsm.b_bus_req = 0;
+				dev_dbg(&lnw->pdev->dev,
+					"LS is not SE0, try again later\n");
 			} else {
 				/* Start SRP */
 				langwell_otg_add_timer(b_srp_res_tmr);
-				langwell_otg_start_srp(&langwell->otg);
+				langwell_otg_start_srp(&lnw->otg);
 				langwell_otg_del_timer(b_srp_res_tmr);
 			}
 		}
 		break;
 	case OTG_STATE_B_SRP_INIT:
-		if (!langwell->hsm.id) {
-			langwell->otg.default_a = 1;
-			langwell->hsm.a_srp_det = 0;
+		if (!lnw->hsm.id) {
+			lnw->otg.default_a = 1;
+			lnw->hsm.a_srp_det = 0;
 			langwell_otg_drv_vbus(0);
 			langwell_otg_chrg_vbus(0);
-			langwell->otg.state = OTG_STATE_A_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.b_sess_vld) {
+			lnw->otg.state = OTG_STATE_A_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.b_sess_vld) {
 			langwell_otg_chrg_vbus(0);
-			if (langwell->client_ops) {
-				langwell->client_ops->resume(langwell->pdev);
-				langwell->otg.state = OTG_STATE_B_PERIPHERAL;
+			if (lnw->client_ops) {
+				lnw->client_ops->resume(lnw->pdev);
+				lnw->otg.state = OTG_STATE_B_PERIPHERAL;
 			} else
-				otg_dbg("client driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver not loaded.\n");
 		}
 		break;
 	case OTG_STATE_B_PERIPHERAL:
-		if (!langwell->hsm.id) {
-			langwell->otg.default_a = 1;
-			langwell->hsm.a_srp_det = 0;
+		if (!lnw->hsm.id) {
+			lnw->otg.default_a = 1;
+			lnw->hsm.a_srp_det = 0;
 
 			langwell_otg_drv_vbus(0);
 			langwell_otg_chrg_vbus(0);
 			set_host_mode();
 
-			if (langwell->client_ops) {
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops) {
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			} else
-				otg_dbg("client driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
 
-			langwell->otg.state = OTG_STATE_A_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (!langwell->hsm.b_sess_vld) {
-			langwell->hsm.b_hnp_enable = 0;
+			lnw->otg.state = OTG_STATE_A_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (!lnw->hsm.b_sess_vld) {
+			lnw->hsm.b_hnp_enable = 0;
 
-			if (langwell->client_ops) {
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops) {
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			} else
-				otg_dbg("client driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
 
-			langwell->otg.state = OTG_STATE_B_IDLE;
-		} else if (langwell->hsm.b_bus_req && langwell->hsm.b_hnp_enable
-			&& langwell->hsm.a_bus_suspend) {
+			lnw->otg.state = OTG_STATE_B_IDLE;
+		} else if (lnw->hsm.b_bus_req && lnw->hsm.b_hnp_enable
+			&& lnw->hsm.a_bus_suspend) {
 
-			if (langwell->client_ops) {
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops) {
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			} else
-				otg_dbg("client driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
 
 			langwell_otg_HAAR(1);
-			langwell->hsm.a_conn = 0;
+			lnw->hsm.a_conn = 0;
 
-			if (langwell->host_ops) {
-				langwell->host_ops->probe(langwell->pdev,
-					langwell->host_ops->id_table);
-				langwell->otg.state = OTG_STATE_B_WAIT_ACON;
+			if (lnw->host_ops) {
+				lnw->host_ops->probe(lnw->pdev,
+					lnw->host_ops->id_table);
+				lnw->otg.state = OTG_STATE_B_WAIT_ACON;
 			} else
-				otg_dbg("host driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver not loaded.\n");
 
-			langwell->hsm.a_bus_resume = 0;
-			langwell->hsm.b_ase0_brst_tmout = 0;
+			lnw->hsm.a_bus_resume = 0;
+			lnw->hsm.b_ase0_brst_tmout = 0;
 			langwell_otg_add_timer(b_ase0_brst_tmr);
 		}
 		break;
 
 	case OTG_STATE_B_WAIT_ACON:
-		if (!langwell->hsm.id) {
+		if (!lnw->hsm.id) {
 			langwell_otg_del_timer(b_ase0_brst_tmr);
-			langwell->otg.default_a = 1;
-			langwell->hsm.a_srp_det = 0;
+			lnw->otg.default_a = 1;
+			lnw->hsm.a_srp_det = 0;
 
 			langwell_otg_drv_vbus(0);
 			langwell_otg_chrg_vbus(0);
 			set_host_mode();
 
 			langwell_otg_HAAR(0);
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
-			langwell->otg.state = OTG_STATE_A_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (!langwell->hsm.b_sess_vld) {
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
+			lnw->otg.state = OTG_STATE_A_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (!lnw->hsm.b_sess_vld) {
 			langwell_otg_del_timer(b_ase0_brst_tmr);
-			langwell->hsm.b_hnp_enable = 0;
-			langwell->hsm.b_bus_req = 0;
+			lnw->hsm.b_hnp_enable = 0;
+			lnw->hsm.b_bus_req = 0;
 			langwell_otg_chrg_vbus(0);
 			langwell_otg_HAAR(0);
 
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
-			langwell->otg.state = OTG_STATE_B_IDLE;
-		} else if (langwell->hsm.a_conn) {
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
+			lnw->otg.state = OTG_STATE_B_IDLE;
+		} else if (lnw->hsm.a_conn) {
 			langwell_otg_del_timer(b_ase0_brst_tmr);
 			langwell_otg_HAAR(0);
-			langwell->otg.state = OTG_STATE_B_HOST;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.a_bus_resume ||
-				langwell->hsm.b_ase0_brst_tmout) {
+			lnw->otg.state = OTG_STATE_B_HOST;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.a_bus_resume ||
+				lnw->hsm.b_ase0_brst_tmout) {
 			langwell_otg_del_timer(b_ase0_brst_tmr);
 			langwell_otg_HAAR(0);
 			langwell_otg_nsf_msg(7);
 
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 
-			langwell->hsm.a_bus_suspend = 0;
-			langwell->hsm.b_bus_req = 0;
+			lnw->hsm.a_bus_suspend = 0;
+			lnw->hsm.b_bus_req = 0;
 
-			if (langwell->client_ops)
-				langwell->client_ops->resume(langwell->pdev);
+			if (lnw->client_ops)
+				lnw->client_ops->resume(lnw->pdev);
 			else
-				otg_dbg("client driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver not loaded.\n");
 
-			langwell->otg.state = OTG_STATE_B_PERIPHERAL;
+			lnw->otg.state = OTG_STATE_B_PERIPHERAL;
 		}
 		break;
 
 	case OTG_STATE_B_HOST:
-		if (!langwell->hsm.id) {
-			langwell->otg.default_a = 1;
-			langwell->hsm.a_srp_det = 0;
+		if (!lnw->hsm.id) {
+			lnw->otg.default_a = 1;
+			lnw->hsm.a_srp_det = 0;
 
 			langwell_otg_drv_vbus(0);
 			langwell_otg_chrg_vbus(0);
 			set_host_mode();
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
-			langwell->otg.state = OTG_STATE_A_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (!langwell->hsm.b_sess_vld) {
-			langwell->hsm.b_hnp_enable = 0;
-			langwell->hsm.b_bus_req = 0;
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
+			lnw->otg.state = OTG_STATE_A_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (!lnw->hsm.b_sess_vld) {
+			lnw->hsm.b_hnp_enable = 0;
+			lnw->hsm.b_bus_req = 0;
 			langwell_otg_chrg_vbus(0);
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
-			langwell->otg.state = OTG_STATE_B_IDLE;
-		} else if ((!langwell->hsm.b_bus_req) ||
-				(!langwell->hsm.a_conn)) {
-			langwell->hsm.b_bus_req = 0;
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
+			lnw->otg.state = OTG_STATE_B_IDLE;
+		} else if ((!lnw->hsm.b_bus_req) ||
+				(!lnw->hsm.a_conn)) {
+			lnw->hsm.b_bus_req = 0;
 			langwell_otg_loc_sof(0);
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 
-			langwell->hsm.a_bus_suspend = 0;
+			lnw->hsm.a_bus_suspend = 0;
 
-			if (langwell->client_ops)
-				langwell->client_ops->resume(langwell->pdev);
+			if (lnw->client_ops)
+				lnw->client_ops->resume(lnw->pdev);
 			else
-				otg_dbg("client driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver not loaded.\n");
 
-			langwell->otg.state = OTG_STATE_B_PERIPHERAL;
+			lnw->otg.state = OTG_STATE_B_PERIPHERAL;
 		}
 		break;
 
 	case OTG_STATE_A_IDLE:
-		langwell->otg.default_a = 1;
-		if (langwell->hsm.id) {
-			langwell->otg.default_a = 0;
-			langwell->hsm.b_bus_req = 0;
-			langwell->hsm.vbus_srp_up = 0;
+		lnw->otg.default_a = 1;
+		if (lnw->hsm.id) {
+			lnw->otg.default_a = 0;
+			lnw->hsm.b_bus_req = 0;
+			lnw->hsm.vbus_srp_up = 0;
 			langwell_otg_drv_vbus(0);
 			langwell_otg_chrg_vbus(0);
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (!langwell->hsm.a_bus_drop &&
-			(langwell->hsm.a_srp_det || langwell->hsm.a_bus_req)) {
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (!lnw->hsm.a_bus_drop &&
+			(lnw->hsm.a_srp_det || lnw->hsm.a_bus_req)) {
 			langwell_otg_drv_vbus(1);
-			langwell->hsm.a_srp_det = 1;
-			langwell->hsm.a_wait_vrise_tmout = 0;
+			lnw->hsm.a_srp_det = 1;
+			lnw->hsm.a_wait_vrise_tmout = 0;
 			langwell_otg_add_timer(a_wait_vrise_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_VRISE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.a_sess_vld) {
-			langwell->hsm.vbus_srp_up = 1;
-		} else if (!langwell->hsm.a_sess_vld &&
-				langwell->hsm.vbus_srp_up) {
+			lnw->otg.state = OTG_STATE_A_WAIT_VRISE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.a_sess_vld) {
+			lnw->hsm.vbus_srp_up = 1;
+		} else if (!lnw->hsm.a_sess_vld &&
+				lnw->hsm.vbus_srp_up) {
 			msleep(10);
 			langwell_otg_drv_vbus(1);
-			langwell->hsm.a_srp_det = 1;
-			langwell->hsm.a_wait_vrise_tmout = 0;
+			lnw->hsm.a_srp_det = 1;
+			lnw->hsm.a_wait_vrise_tmout = 0;
 			langwell_otg_add_timer(a_wait_vrise_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_VRISE;
-			queue_work(langwell->qwork, &langwell->work);
+			lnw->otg.state = OTG_STATE_A_WAIT_VRISE;
+			queue_work(lnw->qwork, &lnw->work);
 		}
 		break;
 	case OTG_STATE_A_WAIT_VRISE:
-		if (langwell->hsm.id) {
+		if (lnw->hsm.id) {
 			langwell_otg_del_timer(a_wait_vrise_tmr);
-			langwell->hsm.b_bus_req = 0;
-			langwell->otg.default_a = 0;
+			lnw->hsm.b_bus_req = 0;
+			lnw->otg.default_a = 0;
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_B_IDLE;
-		} else if (langwell->hsm.a_vbus_vld) {
+			lnw->otg.state = OTG_STATE_B_IDLE;
+		} else if (lnw->hsm.a_vbus_vld) {
 			langwell_otg_del_timer(a_wait_vrise_tmr);
-			if (langwell->host_ops)
-				langwell->host_ops->probe(langwell->pdev,
-						langwell->host_ops->id_table);
+			if (lnw->host_ops)
+				lnw->host_ops->probe(lnw->pdev,
+						lnw->host_ops->id_table);
 			else {
-				otg_dbg("host driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver not loaded.\n");
 				break;
 			}
-			langwell->hsm.b_conn = 0;
-			langwell->hsm.a_wait_bcon_tmout = 0;
+			lnw->hsm.b_conn = 0;
+			lnw->hsm.a_wait_bcon_tmout = 0;
 			langwell_otg_add_timer(a_wait_bcon_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_BCON;
-		} else if (langwell->hsm.a_wait_vrise_tmout) {
-			if (langwell->hsm.a_vbus_vld) {
-				if (langwell->host_ops)
-					langwell->host_ops->probe(
-						langwell->pdev,
-						langwell->host_ops->id_table);
+			lnw->otg.state = OTG_STATE_A_WAIT_BCON;
+		} else if (lnw->hsm.a_wait_vrise_tmout) {
+			if (lnw->hsm.a_vbus_vld) {
+				if (lnw->host_ops)
+					lnw->host_ops->probe(
+						lnw->pdev,
+						lnw->host_ops->id_table);
 				else {
-					otg_dbg("host driver not loaded.\n");
+					dev_dbg(&lnw->pdev->dev,
+						"host driver not loaded.\n");
 					break;
 				}
-				langwell->hsm.b_conn = 0;
-				langwell->hsm.a_wait_bcon_tmout = 0;
+				lnw->hsm.b_conn = 0;
+				lnw->hsm.a_wait_bcon_tmout = 0;
 				langwell_otg_add_timer(a_wait_bcon_tmr);
-				langwell->otg.state = OTG_STATE_A_WAIT_BCON;
+				lnw->otg.state = OTG_STATE_A_WAIT_BCON;
 			} else {
 				langwell_otg_drv_vbus(0);
-				langwell->otg.state = OTG_STATE_A_VBUS_ERR;
+				lnw->otg.state = OTG_STATE_A_VBUS_ERR;
 			}
 		}
 		break;
 	case OTG_STATE_A_WAIT_BCON:
-		if (langwell->hsm.id) {
+		if (lnw->hsm.id) {
 			langwell_otg_del_timer(a_wait_bcon_tmr);
 
-			langwell->otg.default_a = 0;
-			langwell->hsm.b_bus_req = 0;
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			lnw->otg.default_a = 0;
+			lnw->hsm.b_bus_req = 0;
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (!langwell->hsm.a_vbus_vld) {
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (!lnw->hsm.a_vbus_vld) {
 			langwell_otg_del_timer(a_wait_bcon_tmr);
 
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_VBUS_ERR;
-		} else if (langwell->hsm.a_bus_drop ||
-				(langwell->hsm.a_wait_bcon_tmout &&
-				!langwell->hsm.a_bus_req)) {
+			lnw->otg.state = OTG_STATE_A_VBUS_ERR;
+		} else if (lnw->hsm.a_bus_drop ||
+				(lnw->hsm.a_wait_bcon_tmout &&
+				!lnw->hsm.a_bus_req)) {
 			langwell_otg_del_timer(a_wait_bcon_tmr);
 
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
-		} else if (langwell->hsm.b_conn) {
+			lnw->otg.state = OTG_STATE_A_WAIT_VFALL;
+		} else if (lnw->hsm.b_conn) {
 			langwell_otg_del_timer(a_wait_bcon_tmr);
 
-			langwell->hsm.a_suspend_req = 0;
-			langwell->otg.state = OTG_STATE_A_HOST;
-			if (langwell->hsm.a_srp_det &&
-					!langwell->otg.host->b_hnp_enable) {
+			lnw->hsm.a_suspend_req = 0;
+			lnw->otg.state = OTG_STATE_A_HOST;
+			if (lnw->hsm.a_srp_det &&
+					!lnw->otg.host->b_hnp_enable) {
 				/* SRP capable peripheral-only device */
-				langwell->hsm.a_bus_req = 1;
-				langwell->hsm.a_srp_det = 0;
-			} else if (!langwell->hsm.a_bus_req &&
-					langwell->hsm.a_set_b_hnp_en) {
+				lnw->hsm.a_bus_req = 1;
+				lnw->hsm.a_srp_det = 0;
+			} else if (!lnw->hsm.a_bus_req &&
+					lnw->hsm.a_set_b_hnp_en) {
 				/* It is not safe enough to do a fast
 				 * transistion from A_WAIT_BCON to
 				 * A_SUSPEND */
 				msleep(10000);
-				if (langwell->hsm.a_bus_req)
+				if (lnw->hsm.a_bus_req)
 					break;
 
-				if (request_irq(langwell->pdev->irq,
+				if (request_irq(lnw->pdev->irq,
 					otg_dummy_irq, IRQF_SHARED,
-					driver_name, langwell->regs) != 0) {
-					otg_dbg("request interrupt %d fail\n",
-					langwell->pdev->irq);
+					driver_name, lnw->regs) != 0) {
+					dev_dbg(&lnw->pdev->dev,
+						"request interrupt %d fail\n",
+						lnw->pdev->irq);
 				}
 
 				langwell_otg_HABA(1);
-				langwell->hsm.b_bus_resume = 0;
-				langwell->hsm.a_aidl_bdis_tmout = 0;
+				lnw->hsm.b_bus_resume = 0;
+				lnw->hsm.a_aidl_bdis_tmout = 0;
 				langwell_otg_add_timer(a_aidl_bdis_tmr);
 
 				langwell_otg_loc_sof(0);
-				langwell->otg.state = OTG_STATE_A_SUSPEND;
-			} else if (!langwell->hsm.a_bus_req &&
-				!langwell->otg.host->b_hnp_enable) {
-				struct pci_dev *pdev = langwell->pdev;
-				if (langwell->host_ops)
-					langwell->host_ops->remove(pdev);
+				lnw->otg.state = OTG_STATE_A_SUSPEND;
+			} else if (!lnw->hsm.a_bus_req &&
+				!lnw->otg.host->b_hnp_enable) {
+				if (lnw->host_ops)
+					lnw->host_ops->remove(lnw->pdev);
 				else
-					otg_dbg("host driver removed.\n");
+					dev_dbg(&lnw->pdev->dev,
+						"host driver removed.\n");
 				langwell_otg_drv_vbus(0);
-				langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
+				lnw->otg.state = OTG_STATE_A_WAIT_VFALL;
 			}
 		}
 		break;
 	case OTG_STATE_A_HOST:
-		if (langwell->hsm.id) {
-			langwell->otg.default_a = 0;
-			langwell->hsm.b_bus_req = 0;
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+		if (lnw->hsm.id) {
+			lnw->otg.default_a = 0;
+			lnw->hsm.b_bus_req = 0;
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.a_bus_drop ||
-				(!langwell->otg.host->b_hnp_enable &&
-					!langwell->hsm.a_bus_req)) {
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.a_bus_drop ||
+				(!lnw->otg.host->b_hnp_enable &&
+					!lnw->hsm.a_bus_req)) {
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
-		} else if (!langwell->hsm.a_vbus_vld) {
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			lnw->otg.state = OTG_STATE_A_WAIT_VFALL;
+		} else if (!lnw->hsm.a_vbus_vld) {
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_VBUS_ERR;
-		} else if (langwell->otg.host->b_hnp_enable
-				&& !langwell->hsm.a_bus_req) {
+			lnw->otg.state = OTG_STATE_A_VBUS_ERR;
+		} else if (lnw->otg.host->b_hnp_enable
+				&& !lnw->hsm.a_bus_req) {
 			/* Set HABA to enable hardware assistance to signal
 			 *  A-connect after receiver B-disconnect. Hardware
 			 *  will then set client mode and enable URE, SLE and
 			 *  PCE after the assistance. otg_dummy_irq is used to
 			 *  clean these ints when client driver is not resumed.
 			 */
-			if (request_irq(langwell->pdev->irq,
+			if (request_irq(lnw->pdev->irq,
 				otg_dummy_irq, IRQF_SHARED, driver_name,
-				langwell->regs) != 0) {
-				otg_dbg("request interrupt %d failed\n",
-						langwell->pdev->irq);
+				lnw->regs) != 0) {
+				dev_dbg(&lnw->pdev->dev,
+					"request interrupt %d failed\n",
+						lnw->pdev->irq);
 			}
 
 			/* set HABA */
 			langwell_otg_HABA(1);
-			langwell->hsm.b_bus_resume = 0;
-			langwell->hsm.a_aidl_bdis_tmout = 0;
+			lnw->hsm.b_bus_resume = 0;
+			lnw->hsm.a_aidl_bdis_tmout = 0;
 			langwell_otg_add_timer(a_aidl_bdis_tmr);
 			langwell_otg_loc_sof(0);
-			langwell->otg.state = OTG_STATE_A_SUSPEND;
-		} else if (!langwell->hsm.b_conn || !langwell->hsm.a_bus_req) {
-			langwell->hsm.a_wait_bcon_tmout = 0;
+			lnw->otg.state = OTG_STATE_A_SUSPEND;
+		} else if (!lnw->hsm.b_conn || !lnw->hsm.a_bus_req) {
+			lnw->hsm.a_wait_bcon_tmout = 0;
 			langwell_otg_add_timer(a_wait_bcon_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_BCON;
+			lnw->otg.state = OTG_STATE_A_WAIT_BCON;
 		}
 		break;
 	case OTG_STATE_A_SUSPEND:
-		if (langwell->hsm.id) {
+		if (lnw->hsm.id) {
 			langwell_otg_del_timer(a_aidl_bdis_tmr);
 			langwell_otg_HABA(0);
-			free_irq(langwell->pdev->irq, langwell->regs);
-			langwell->otg.default_a = 0;
-			langwell->hsm.b_bus_req = 0;
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			free_irq(lnw->pdev->irq, lnw->regs);
+			lnw->otg.default_a = 0;
+			lnw->hsm.b_bus_req = 0;
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.a_bus_req ||
-				langwell->hsm.b_bus_resume) {
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.a_bus_req ||
+				lnw->hsm.b_bus_resume) {
 			langwell_otg_del_timer(a_aidl_bdis_tmr);
 			langwell_otg_HABA(0);
-			free_irq(langwell->pdev->irq, langwell->regs);
-			langwell->hsm.a_suspend_req = 0;
+			free_irq(lnw->pdev->irq, lnw->regs);
+			lnw->hsm.a_suspend_req = 0;
 			langwell_otg_loc_sof(1);
-			langwell->otg.state = OTG_STATE_A_HOST;
-		} else if (langwell->hsm.a_aidl_bdis_tmout ||
-				langwell->hsm.a_bus_drop) {
+			lnw->otg.state = OTG_STATE_A_HOST;
+		} else if (lnw->hsm.a_aidl_bdis_tmout ||
+				lnw->hsm.a_bus_drop) {
 			langwell_otg_del_timer(a_aidl_bdis_tmr);
 			langwell_otg_HABA(0);
-			free_irq(langwell->pdev->irq, langwell->regs);
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			free_irq(lnw->pdev->irq, lnw->regs);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
-		} else if (!langwell->hsm.b_conn &&
-				langwell->otg.host->b_hnp_enable) {
+			lnw->otg.state = OTG_STATE_A_WAIT_VFALL;
+		} else if (!lnw->hsm.b_conn &&
+				lnw->otg.host->b_hnp_enable) {
 			langwell_otg_del_timer(a_aidl_bdis_tmr);
 			langwell_otg_HABA(0);
-			free_irq(langwell->pdev->irq, langwell->regs);
+			free_irq(lnw->pdev->irq, lnw->regs);
 
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 
-			langwell->hsm.b_bus_suspend = 0;
-			langwell->hsm.b_bus_suspend_vld = 0;
-			langwell->hsm.b_bus_suspend_tmout = 0;
+			lnw->hsm.b_bus_suspend = 0;
+			lnw->hsm.b_bus_suspend_vld = 0;
+			lnw->hsm.b_bus_suspend_tmout = 0;
 
 			/* msleep(200); */
-			if (langwell->client_ops)
-				langwell->client_ops->resume(langwell->pdev);
+			if (lnw->client_ops)
+				lnw->client_ops->resume(lnw->pdev);
 			else
-				otg_dbg("client driver not loaded.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver not loaded.\n");
 
 			langwell_otg_add_timer(b_bus_suspend_tmr);
-			langwell->otg.state = OTG_STATE_A_PERIPHERAL;
+			lnw->otg.state = OTG_STATE_A_PERIPHERAL;
 			break;
-		} else if (!langwell->hsm.a_vbus_vld) {
+		} else if (!lnw->hsm.a_vbus_vld) {
 			langwell_otg_del_timer(a_aidl_bdis_tmr);
 			langwell_otg_HABA(0);
-			free_irq(langwell->pdev->irq, langwell->regs);
-			if (langwell->host_ops)
-				langwell->host_ops->remove(langwell->pdev);
+			free_irq(lnw->pdev->irq, lnw->regs);
+			if (lnw->host_ops)
+				lnw->host_ops->remove(lnw->pdev);
 			else
-				otg_dbg("host driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"host driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_VBUS_ERR;
+			lnw->otg.state = OTG_STATE_A_VBUS_ERR;
 		}
 		break;
 	case OTG_STATE_A_PERIPHERAL:
-		if (langwell->hsm.id) {
+		if (lnw->hsm.id) {
 			langwell_otg_del_timer(b_bus_suspend_tmr);
-			langwell->otg.default_a = 0;
-			langwell->hsm.b_bus_req = 0;
-			if (langwell->client_ops)
-				langwell->client_ops->suspend(langwell->pdev,
+			lnw->otg.default_a = 0;
+			lnw->hsm.b_bus_req = 0;
+			if (lnw->client_ops)
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			else
-				otg_dbg("client driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (!langwell->hsm.a_vbus_vld) {
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (!lnw->hsm.a_vbus_vld) {
 			langwell_otg_del_timer(b_bus_suspend_tmr);
-			if (langwell->client_ops)
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops)
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			else
-				otg_dbg("client driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_VBUS_ERR;
-		} else if (langwell->hsm.a_bus_drop) {
+			lnw->otg.state = OTG_STATE_A_VBUS_ERR;
+		} else if (lnw->hsm.a_bus_drop) {
 			langwell_otg_del_timer(b_bus_suspend_tmr);
-			if (langwell->client_ops)
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops)
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			else
-				otg_dbg("client driver has been removed.\n");
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
 			langwell_otg_drv_vbus(0);
-			langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
-		} else if (langwell->hsm.b_bus_suspend) {
+			lnw->otg.state = OTG_STATE_A_WAIT_VFALL;
+		} else if (lnw->hsm.b_bus_suspend) {
 			langwell_otg_del_timer(b_bus_suspend_tmr);
-			if (langwell->client_ops)
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops)
+				lnw->client_ops->suspend(lnw->pdev,
 					PMSG_FREEZE);
 			else
-				otg_dbg("client driver has been removed.\n");
-			if (langwell->host_ops)
-				langwell->host_ops->probe(langwell->pdev,
-						langwell->host_ops->id_table);
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
+			if (lnw->host_ops)
+				lnw->host_ops->probe(lnw->pdev,
+						lnw->host_ops->id_table);
 			else
-				otg_dbg("host driver not loaded.\n");
-			langwell->hsm.a_wait_bcon_tmout = 0;
+				dev_dbg(&lnw->pdev->dev,
+					"host driver not loaded.\n");
+			lnw->hsm.a_wait_bcon_tmout = 0;
 			langwell_otg_add_timer(a_wait_bcon_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_BCON;
-		} else if (langwell->hsm.b_bus_suspend_tmout) {
+			lnw->otg.state = OTG_STATE_A_WAIT_BCON;
+		} else if (lnw->hsm.b_bus_suspend_tmout) {
 			u32	val;
-			val = readl(langwell->regs + CI_PORTSC1);
+			val = readl(lnw->regs + CI_PORTSC1);
 			if (!(val & PORTSC_SUSP))
 				break;
-			if (langwell->client_ops)
-				langwell->client_ops->suspend(langwell->pdev,
+			if (lnw->client_ops)
+				lnw->client_ops->suspend(lnw->pdev,
 						PMSG_FREEZE);
 			else
-				otg_dbg("client driver has been removed.\n");
-			if (langwell->host_ops)
-				langwell->host_ops->probe(langwell->pdev,
-						langwell->host_ops->id_table);
+				dev_dbg(&lnw->pdev->dev,
+					"client driver has been removed.\n");
+			if (lnw->host_ops)
+				lnw->host_ops->probe(lnw->pdev,
+						lnw->host_ops->id_table);
 			else
-				otg_dbg("host driver not loaded.\n");
-			langwell->hsm.a_wait_bcon_tmout = 0;
+				dev_dbg(&lnw->pdev->dev,
+					"host driver not loaded.\n");
+			lnw->hsm.a_wait_bcon_tmout = 0;
 			langwell_otg_add_timer(a_wait_bcon_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_BCON;
+			lnw->otg.state = OTG_STATE_A_WAIT_BCON;
 		}
 		break;
 	case OTG_STATE_A_VBUS_ERR:
-		if (langwell->hsm.id) {
-			langwell->otg.default_a = 0;
-			langwell->hsm.a_clr_err = 0;
-			langwell->hsm.a_srp_det = 0;
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.a_clr_err) {
-			langwell->hsm.a_clr_err = 0;
-			langwell->hsm.a_srp_det = 0;
+		if (lnw->hsm.id) {
+			lnw->otg.default_a = 0;
+			lnw->hsm.a_clr_err = 0;
+			lnw->hsm.a_srp_det = 0;
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.a_clr_err) {
+			lnw->hsm.a_clr_err = 0;
+			lnw->hsm.a_srp_det = 0;
 			reset_otg();
 			init_hsm();
-			if (langwell->otg.state == OTG_STATE_A_IDLE)
-				queue_work(langwell->qwork, &langwell->work);
+			if (lnw->otg.state == OTG_STATE_A_IDLE)
+				queue_work(lnw->qwork, &lnw->work);
 		}
 		break;
 	case OTG_STATE_A_WAIT_VFALL:
-		if (langwell->hsm.id) {
-			langwell->otg.default_a = 0;
-			langwell->otg.state = OTG_STATE_B_IDLE;
-			queue_work(langwell->qwork, &langwell->work);
-		} else if (langwell->hsm.a_bus_req) {
+		if (lnw->hsm.id) {
+			lnw->otg.default_a = 0;
+			lnw->otg.state = OTG_STATE_B_IDLE;
+			queue_work(lnw->qwork, &lnw->work);
+		} else if (lnw->hsm.a_bus_req) {
 			langwell_otg_drv_vbus(1);
-			langwell->hsm.a_wait_vrise_tmout = 0;
+			lnw->hsm.a_wait_vrise_tmout = 0;
 			langwell_otg_add_timer(a_wait_vrise_tmr);
-			langwell->otg.state = OTG_STATE_A_WAIT_VRISE;
-		} else if (!langwell->hsm.a_sess_vld) {
-			langwell->hsm.a_srp_det = 0;
+			lnw->otg.state = OTG_STATE_A_WAIT_VRISE;
+		} else if (!lnw->hsm.a_sess_vld) {
+			lnw->hsm.a_srp_det = 0;
 			langwell_otg_drv_vbus(0);
 			set_host_mode();
-			langwell->otg.state = OTG_STATE_A_IDLE;
+			lnw->otg.state = OTG_STATE_A_IDLE;
 		}
 		break;
 	default:
 		;
 	}
 
-	otg_dbg("%s: new state = %s\n", __func__,
-			state_string(langwell->otg.state));
+	dev_dbg(&lnw->pdev->dev, "%s: new state = %s\n", __func__,
+			state_string(lnw->otg.state));
 }
 
-	static ssize_t
+static ssize_t
 show_registers(struct device *_dev, struct device_attribute *attr, char *buf)
 {
-	struct langwell_otg *langwell;
-	char *next;
-	unsigned size;
-	unsigned t;
+	struct langwell_otg	*lnw = the_transceiver;
+	char			*next;
+	unsigned		size, t;
 
-	langwell = the_transceiver;
 	next = buf;
 	size = PAGE_SIZE;
 
 	t = scnprintf(next, size,
 		"\n"
-		"USBCMD = 0x%08x \n"
-		"USBSTS = 0x%08x \n"
-		"USBINTR = 0x%08x \n"
-		"ASYNCLISTADDR = 0x%08x \n"
-		"PORTSC1 = 0x%08x \n"
-		"HOSTPC1 = 0x%08x \n"
-		"OTGSC = 0x%08x \n"
-		"USBMODE = 0x%08x \n",
-		readl(langwell->regs + 0x30),
-		readl(langwell->regs + 0x34),
-		readl(langwell->regs + 0x38),
-		readl(langwell->regs + 0x48),
-		readl(langwell->regs + 0x74),
-		readl(langwell->regs + 0xb4),
-		readl(langwell->regs + 0xf4),
-		readl(langwell->regs + 0xf8)
+		"USBCMD = 0x%08x\n"
+		"USBSTS = 0x%08x\n"
+		"USBINTR = 0x%08x\n"
+		"ASYNCLISTADDR = 0x%08x\n"
+		"PORTSC1 = 0x%08x\n"
+		"HOSTPC1 = 0x%08x\n"
+		"OTGSC = 0x%08x\n"
+		"USBMODE = 0x%08x\n",
+		readl(lnw->regs + 0x30),
+		readl(lnw->regs + 0x34),
+		readl(lnw->regs + 0x38),
+		readl(lnw->regs + 0x48),
+		readl(lnw->regs + 0x74),
+		readl(lnw->regs + 0xb4),
+		readl(lnw->regs + 0xf4),
+		readl(lnw->regs + 0xf8)
 		);
 	size -= t;
 	next += t;
@@ -1320,12 +1393,10 @@ static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
 static ssize_t
 show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
 {
-	struct langwell_otg *langwell;
-	char *next;
-	unsigned size;
-	unsigned t;
+	struct langwell_otg	*lnw = the_transceiver;
+	char			*next;
+	unsigned		size, t;
 
-	langwell = the_transceiver;
 	next = buf;
 	size = PAGE_SIZE;
 
@@ -1358,33 +1429,33 @@ show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
 		"b_bus_req = \t%d\n"
 		"b_bus_suspend_tmout = \t%d\n"
 		"b_bus_suspend_vld = \t%d\n",
-		state_string(langwell->otg.state),
-		langwell->hsm.a_bus_resume,
-		langwell->hsm.a_bus_suspend,
-		langwell->hsm.a_conn,
-		langwell->hsm.a_sess_vld,
-		langwell->hsm.a_srp_det,
-		langwell->hsm.a_vbus_vld,
-		langwell->hsm.b_bus_resume,
-		langwell->hsm.b_bus_suspend,
-		langwell->hsm.b_conn,
-		langwell->hsm.b_se0_srp,
-		langwell->hsm.b_sess_end,
-		langwell->hsm.b_sess_vld,
-		langwell->hsm.id,
-		langwell->hsm.b_srp_done,
-		langwell->hsm.b_hnp_enable,
-		langwell->hsm.a_wait_vrise_tmout,
-		langwell->hsm.a_wait_bcon_tmout,
-		langwell->hsm.a_aidl_bdis_tmout,
-		langwell->hsm.b_ase0_brst_tmout,
-		langwell->hsm.a_bus_drop,
-		langwell->hsm.a_bus_req,
-		langwell->hsm.a_clr_err,
-		langwell->hsm.a_suspend_req,
-		langwell->hsm.b_bus_req,
-		langwell->hsm.b_bus_suspend_tmout,
-		langwell->hsm.b_bus_suspend_vld
+		state_string(lnw->otg.state),
+		lnw->hsm.a_bus_resume,
+		lnw->hsm.a_bus_suspend,
+		lnw->hsm.a_conn,
+		lnw->hsm.a_sess_vld,
+		lnw->hsm.a_srp_det,
+		lnw->hsm.a_vbus_vld,
+		lnw->hsm.b_bus_resume,
+		lnw->hsm.b_bus_suspend,
+		lnw->hsm.b_conn,
+		lnw->hsm.b_se0_srp,
+		lnw->hsm.b_sess_end,
+		lnw->hsm.b_sess_vld,
+		lnw->hsm.id,
+		lnw->hsm.b_srp_done,
+		lnw->hsm.b_hnp_enable,
+		lnw->hsm.a_wait_vrise_tmout,
+		lnw->hsm.a_wait_bcon_tmout,
+		lnw->hsm.a_aidl_bdis_tmout,
+		lnw->hsm.b_ase0_brst_tmout,
+		lnw->hsm.a_bus_drop,
+		lnw->hsm.a_bus_req,
+		lnw->hsm.a_clr_err,
+		lnw->hsm.a_suspend_req,
+		lnw->hsm.b_bus_req,
+		lnw->hsm.b_bus_suspend_tmout,
+		lnw->hsm.b_bus_suspend_vld
 		);
 	size -= t;
 	next += t;
@@ -1396,16 +1467,14 @@ static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL);
 static ssize_t
 get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct langwell_otg *langwell;
-	char *next;
-	unsigned size;
-	unsigned t;
+	struct langwell_otg	*lnw = the_transceiver;
+	char			*next;
+	unsigned		size, t;
 
-	langwell =  the_transceiver;
 	next = buf;
 	size = PAGE_SIZE;
 
-	t = scnprintf(next, size, "%d", langwell->hsm.a_bus_req);
+	t = scnprintf(next, size, "%d", lnw->hsm.a_bus_req);
 	size -= t;
 	next += t;
 
@@ -1416,26 +1485,26 @@ static ssize_t
 set_a_bus_req(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct langwell_otg *langwell;
-	langwell = the_transceiver;
-	if (!langwell->otg.default_a)
+	struct langwell_otg	*lnw = the_transceiver;
+
+	if (!lnw->otg.default_a)
 		return -1;
 	if (count > 2)
 		return -1;
 
 	if (buf[0] == '0') {
-		langwell->hsm.a_bus_req = 0;
-		otg_dbg("a_bus_req = 0\n");
+		lnw->hsm.a_bus_req = 0;
+		dev_dbg(&lnw->pdev->dev, "User request: a_bus_req = 0\n");
 	} else if (buf[0] == '1') {
 		/* If a_bus_drop is TRUE, a_bus_req can't be set */
-		if (langwell->hsm.a_bus_drop)
+		if (lnw->hsm.a_bus_drop)
 			return -1;
-		langwell->hsm.a_bus_req = 1;
-		otg_dbg("a_bus_req = 1\n");
+		lnw->hsm.a_bus_req = 1;
+		dev_dbg(&lnw->pdev->dev, "User request: a_bus_req = 1\n");
 	}
-	if (spin_trylock(&langwell->wq_lock)) {
-		queue_work(langwell->qwork, &langwell->work);
-		spin_unlock(&langwell->wq_lock);
+	if (spin_trylock(&lnw->wq_lock)) {
+		queue_work(lnw->qwork, &lnw->work);
+		spin_unlock(&lnw->wq_lock);
 	}
 	return count;
 }
@@ -1444,16 +1513,14 @@ static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUGO, get_a_bus_req, set_a_bus_req);
 static ssize_t
 get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct langwell_otg *langwell;
-	char *next;
-	unsigned size;
-	unsigned t;
+	struct langwell_otg	*lnw = the_transceiver;
+	char			*next;
+	unsigned		size, t;
 
-	langwell =  the_transceiver;
 	next = buf;
 	size = PAGE_SIZE;
 
-	t = scnprintf(next, size, "%d", langwell->hsm.a_bus_drop);
+	t = scnprintf(next, size, "%d", lnw->hsm.a_bus_drop);
 	size -= t;
 	next += t;
 
@@ -1464,24 +1531,25 @@ static ssize_t
 set_a_bus_drop(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct langwell_otg *langwell;
-	langwell = the_transceiver;
-	if (!langwell->otg.default_a)
+	struct langwell_otg	*lnw = the_transceiver;
+
+	if (!lnw->otg.default_a)
 		return -1;
 	if (count > 2)
 		return -1;
 
 	if (buf[0] == '0') {
-		langwell->hsm.a_bus_drop = 0;
-		otg_dbg("a_bus_drop = 0\n");
+		lnw->hsm.a_bus_drop = 0;
+		dev_dbg(&lnw->pdev->dev, "User request: a_bus_drop = 0\n");
 	} else if (buf[0] == '1') {
-		langwell->hsm.a_bus_drop = 1;
-		langwell->hsm.a_bus_req = 0;
-		otg_dbg("a_bus_drop = 1, then a_bus_req = 0\n");
+		lnw->hsm.a_bus_drop = 1;
+		lnw->hsm.a_bus_req = 0;
+		dev_dbg(&lnw->pdev->dev, "User request: a_bus_drop = 1\n");
+		dev_dbg(&lnw->pdev->dev, "User request: and a_bus_req = 0\n");
 	}
-	if (spin_trylock(&langwell->wq_lock)) {
-		queue_work(langwell->qwork, &langwell->work);
-		spin_unlock(&langwell->wq_lock);
+	if (spin_trylock(&lnw->wq_lock)) {
+		queue_work(lnw->qwork, &lnw->work);
+		spin_unlock(&lnw->wq_lock);
 	}
 	return count;
 }
@@ -1491,16 +1559,14 @@ static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUGO,
 static ssize_t
 get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct langwell_otg *langwell;
-	char *next;
-	unsigned size;
-	unsigned t;
+	struct langwell_otg	*lnw = the_transceiver;
+	char			*next;
+	unsigned		size, t;
 
-	langwell =  the_transceiver;
 	next = buf;
 	size = PAGE_SIZE;
 
-	t = scnprintf(next, size, "%d", langwell->hsm.b_bus_req);
+	t = scnprintf(next, size, "%d", lnw->hsm.b_bus_req);
 	size -= t;
 	next += t;
 
@@ -1511,25 +1577,24 @@ static ssize_t
 set_b_bus_req(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct langwell_otg *langwell;
-	langwell = the_transceiver;
+	struct langwell_otg *lnw = the_transceiver;
 
-	if (langwell->otg.default_a)
+	if (lnw->otg.default_a)
 		return -1;
 
 	if (count > 2)
 		return -1;
 
 	if (buf[0] == '0') {
-		langwell->hsm.b_bus_req = 0;
-		otg_dbg("b_bus_req = 0\n");
+		lnw->hsm.b_bus_req = 0;
+		dev_dbg(&lnw->pdev->dev, "User request: b_bus_req = 0\n");
 	} else if (buf[0] == '1') {
-		langwell->hsm.b_bus_req = 1;
-		otg_dbg("b_bus_req = 1\n");
+		lnw->hsm.b_bus_req = 1;
+		dev_dbg(&lnw->pdev->dev, "User request: b_bus_req = 1\n");
 	}
-	if (spin_trylock(&langwell->wq_lock)) {
-		queue_work(langwell->qwork, &langwell->work);
-		spin_unlock(&langwell->wq_lock);
+	if (spin_trylock(&lnw->wq_lock)) {
+		queue_work(lnw->qwork, &lnw->work);
+		spin_unlock(&lnw->wq_lock);
 	}
 	return count;
 }
@@ -1539,21 +1604,20 @@ static ssize_t
 set_a_clr_err(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct langwell_otg *langwell;
-	langwell = the_transceiver;
+	struct langwell_otg *lnw = the_transceiver;
 
-	if (!langwell->otg.default_a)
+	if (!lnw->otg.default_a)
 		return -1;
 	if (count > 2)
 		return -1;
 
 	if (buf[0] == '1') {
-		langwell->hsm.a_clr_err = 1;
-		otg_dbg("a_clr_err = 1\n");
+		lnw->hsm.a_clr_err = 1;
+		dev_dbg(&lnw->pdev->dev, "User request: a_clr_err = 1\n");
 	}
-	if (spin_trylock(&langwell->wq_lock)) {
-		queue_work(langwell->qwork, &langwell->work);
-		spin_unlock(&langwell->wq_lock);
+	if (spin_trylock(&lnw->wq_lock)) {
+		queue_work(lnw->qwork, &lnw->work);
+		spin_unlock(&lnw->wq_lock);
 	}
 	return count;
 }
@@ -1574,11 +1638,12 @@ static struct attribute_group debug_dev_attr_group = {
 
 int langwell_register_host(struct pci_driver *host_driver)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	int	ret = 0;
 
-	the_transceiver->host_ops = host_driver;
-	queue_work(the_transceiver->qwork, &the_transceiver->work);
-	otg_dbg("host controller driver is registered\n");
+	lnw->host_ops = host_driver;
+	queue_work(lnw->qwork, &lnw->work);
+	dev_dbg(&lnw->pdev->dev, "host controller driver is registered\n");
 
 	return ret;
 }
@@ -1586,26 +1651,30 @@ EXPORT_SYMBOL(langwell_register_host);
 
 void langwell_unregister_host(struct pci_driver *host_driver)
 {
-	if (the_transceiver->host_ops)
-		the_transceiver->host_ops->remove(the_transceiver->pdev);
-	the_transceiver->host_ops = NULL;
-	the_transceiver->hsm.a_bus_drop = 1;
-	queue_work(the_transceiver->qwork, &the_transceiver->work);
-	otg_dbg("host controller driver is unregistered\n");
+	struct langwell_otg	*lnw = the_transceiver;
+
+	if (lnw->host_ops)
+		lnw->host_ops->remove(lnw->pdev);
+	lnw->host_ops = NULL;
+	lnw->hsm.a_bus_drop = 1;
+	queue_work(lnw->qwork, &lnw->work);
+	dev_dbg(&lnw->pdev->dev, "host controller driver is unregistered\n");
 }
 EXPORT_SYMBOL(langwell_unregister_host);
 
 int langwell_register_peripheral(struct pci_driver *client_driver)
 {
+	struct langwell_otg	*lnw = the_transceiver;
 	int	ret = 0;
 
 	if (client_driver)
-		ret = client_driver->probe(the_transceiver->pdev,
+		ret = client_driver->probe(lnw->pdev,
 				client_driver->id_table);
 	if (!ret) {
-		the_transceiver->client_ops = client_driver;
-		queue_work(the_transceiver->qwork, &the_transceiver->work);
-		otg_dbg("client controller driver is registered\n");
+		lnw->client_ops = client_driver;
+		queue_work(lnw->qwork, &lnw->work);
+		dev_dbg(&lnw->pdev->dev,
+			"client controller driver is registered\n");
 	}
 
 	return ret;
@@ -1614,12 +1683,15 @@ EXPORT_SYMBOL(langwell_register_peripheral);
 
 void langwell_unregister_peripheral(struct pci_driver *client_driver)
 {
-	if (the_transceiver->client_ops)
-		the_transceiver->client_ops->remove(the_transceiver->pdev);
-	the_transceiver->client_ops = NULL;
-	the_transceiver->hsm.b_bus_req = 0;
-	queue_work(the_transceiver->qwork, &the_transceiver->work);
-	otg_dbg("client controller driver is unregistered\n");
+	struct langwell_otg	*lnw = the_transceiver;
+
+	if (lnw->client_ops)
+		lnw->client_ops->remove(lnw->pdev);
+	lnw->client_ops = NULL;
+	lnw->hsm.b_bus_req = 0;
+	queue_work(lnw->qwork, &lnw->work);
+	dev_dbg(&lnw->pdev->dev,
+		"client controller driver is unregistered\n");
 }
 EXPORT_SYMBOL(langwell_unregister_peripheral);
 
@@ -1627,14 +1699,14 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 		const struct pci_device_id *id)
 {
 	unsigned long		resource, len;
-	void __iomem 		*base = NULL;
+	void __iomem		*base = NULL;
 	int			retval;
 	u32			val32;
 	struct langwell_otg	*langwell;
 	char			qname[] = "langwell_otg_queue";
 
 	retval = 0;
-	otg_dbg("\notg controller is detected.\n");
+	dev_dbg(&pdev->dev, "\notg controller is detected.\n");
 	if (pci_enable_device(pdev) < 0) {
 		retval = -ENODEV;
 		goto done;
@@ -1664,14 +1736,14 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 	langwell->regs = base;
 
 	if (!pdev->irq) {
-		otg_dbg("No IRQ.\n");
+		dev_dbg(&pdev->dev, "No IRQ.\n");
 		retval = -ENODEV;
 		goto err;
 	}
 
 	langwell->qwork = create_singlethread_workqueue(qname);
 	if (!langwell->qwork) {
-		otg_dbg("cannot create workqueue %s\n", qname);
+		dev_dbg(&pdev->dev, "cannot create workqueue %s\n", qname);
 		retval = -ENOMEM;
 		goto err;
 	}
@@ -1687,7 +1759,7 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 	langwell->otg.start_srp = langwell_otg_start_srp;
 	langwell->otg.state = OTG_STATE_UNDEFINED;
 	if (otg_set_transceiver(&langwell->otg)) {
-		otg_dbg("can't set transceiver\n");
+		dev_dbg(&pdev->dev, "can't set transceiver\n");
 		retval = -EBUSY;
 		goto err;
 	}
@@ -1702,7 +1774,7 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 
 	if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
 				driver_name, langwell) != 0) {
-		otg_dbg("request interrupt %d failed\n", pdev->irq);
+		dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq);
 		retval = -EBUSY;
 		goto err;
 	}
@@ -1714,19 +1786,21 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 
 	retval = device_create_file(&pdev->dev, &dev_attr_registers);
 	if (retval < 0) {
-		otg_dbg("Can't register sysfs attribute: %d\n", retval);
+		dev_dbg(&pdev->dev, "Can't register sysfs attribute: %d\n",
+					 retval);
 		goto err;
 	}
 
 	retval = device_create_file(&pdev->dev, &dev_attr_hsm);
 	if (retval < 0) {
-		otg_dbg("Can't hsm sysfs attribute: %d\n", retval);
+		dev_dbg(&pdev->dev, "Can't hsm sysfs attribute: %d\n", retval);
 		goto err;
 	}
 
 	retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group);
 	if (retval < 0) {
-		otg_dbg("Can't register sysfs attr group: %d\n", retval);
+		dev_dbg(&pdev->dev, "Can't register sysfs attr group: %d\n",
+					retval);
 		goto err;
 	}
 
@@ -1783,10 +1857,8 @@ static void transceiver_suspend(struct pci_dev *pdev)
 
 static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 {
-	int 	ret = 0;
-	struct langwell_otg *langwell;
-
-	langwell = the_transceiver;
+	struct langwell_otg	*langwell = the_transceiver;
+	int			ret = 0;
 
 	/* Disbale OTG interrupts */
 	langwell_otg_intr(0);
@@ -1818,14 +1890,14 @@ static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 		if (langwell->host_ops)
 			ret = langwell->host_ops->suspend(pdev, message);
 		else
-			otg_dbg("host driver has been removed.\n");
+			dev_dbg(&pdev->dev, "host driver has been removed.\n");
 		langwell_otg_drv_vbus(0);
 		break;
 	case OTG_STATE_A_HOST:
 		if (langwell->host_ops)
 			ret = langwell->host_ops->suspend(pdev, message);
 		else
-			otg_dbg("host driver has been removed.\n");
+			dev_dbg(&pdev->dev, "host driver has been removed.\n");
 		langwell_otg_drv_vbus(0);
 		langwell_otg_phy_low_power(1);
 		break;
@@ -1835,7 +1907,7 @@ static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 		if (langwell->host_ops)
 			langwell->host_ops->remove(pdev);
 		else
-			otg_dbg("host driver has been removed.\n");
+			dev_dbg(&pdev->dev, "host driver has been removed.\n");
 		langwell_otg_drv_vbus(0);
 		transceiver_suspend(pdev);
 		langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
@@ -1844,7 +1916,8 @@ static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 		if (langwell->client_ops)
 			ret = langwell->client_ops->suspend(pdev, message);
 		else
-			otg_dbg("client driver has been removed.\n");
+			dev_dbg(&pdev->dev,
+				"client driver has been removed.\n");
 		langwell_otg_drv_vbus(0);
 		transceiver_suspend(pdev);
 		langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
@@ -1853,7 +1926,7 @@ static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 		if (langwell->host_ops)
 			langwell->host_ops->remove(pdev);
 		else
-			otg_dbg("host driver has been removed.\n");
+			dev_dbg(&pdev->dev, "host driver has been removed.\n");
 		langwell->hsm.b_bus_req = 0;
 		transceiver_suspend(pdev);
 		langwell->otg.state = OTG_STATE_B_IDLE;
@@ -1862,7 +1935,8 @@ static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 		if (langwell->client_ops)
 			ret = langwell->client_ops->suspend(pdev, message);
 		else
-			otg_dbg("client driver has been removed.\n");
+			dev_dbg(&pdev->dev,
+				"client driver has been removed.\n");
 		break;
 	case OTG_STATE_B_WAIT_ACON:
 		langwell_otg_del_timer(b_ase0_brst_tmr);
@@ -1870,13 +1944,13 @@ static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
 		if (langwell->host_ops)
 			langwell->host_ops->remove(pdev);
 		else
-			otg_dbg("host driver has been removed.\n");
+			dev_dbg(&pdev->dev, "host driver has been removed.\n");
 		langwell->hsm.b_bus_req = 0;
 		langwell->otg.state = OTG_STATE_B_IDLE;
 		transceiver_suspend(pdev);
 		break;
 	default:
-		otg_dbg("error state before suspend\n ");
+		dev_dbg(&pdev->dev, "error state before suspend\n ");
 		break;
 	}
 	spin_unlock(&langwell->wq_lock);
@@ -1893,10 +1967,8 @@ static void transceiver_resume(struct pci_dev *pdev)
 
 static int langwell_otg_resume(struct pci_dev *pdev)
 {
-	int 	ret = 0;
-	struct langwell_otg *langwell;
-
-	langwell = the_transceiver;
+	struct langwell_otg	*langwell = the_transceiver;
+	int			ret = 0;
 
 	spin_lock(&langwell->wq_lock);
 
@@ -1913,7 +1985,7 @@ static int langwell_otg_resume(struct pci_dev *pdev)
 		if (langwell->host_ops)
 			ret = langwell->host_ops->resume(pdev);
 		else
-			otg_dbg("host driver not loaded.\n");
+			dev_dbg(&pdev->dev, "host driver not loaded.\n");
 		break;
 	case OTG_STATE_A_HOST:
 		langwell_otg_drv_vbus(1);
@@ -1921,22 +1993,22 @@ static int langwell_otg_resume(struct pci_dev *pdev)
 		if (langwell->host_ops)
 			ret = langwell->host_ops->resume(pdev);
 		else
-			otg_dbg("host driver not loaded.\n");
+			dev_dbg(&pdev->dev, "host driver not loaded.\n");
 		break;
 	case OTG_STATE_B_PERIPHERAL:
 		if (langwell->client_ops)
 			ret = langwell->client_ops->resume(pdev);
 		else
-			otg_dbg("client driver not loaded.\n");
+			dev_dbg(&pdev->dev, "client driver not loaded.\n");
 		break;
 	default:
-		otg_dbg("error state before suspend\n ");
+		dev_dbg(&pdev->dev, "error state before suspend\n ");
 		break;
 	}
 
 	if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
-				driver_name, the_transceiver) != 0) {
-		otg_dbg("request interrupt %d failed\n", pdev->irq);
+				driver_name, langwell) != 0) {
+		dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq);
 		ret = -EBUSY;
 	}
 
diff --git a/include/linux/usb/langwell_otg.h b/include/linux/usb/langwell_otg.h
index c05a6f9..7619871 100644
--- a/include/linux/usb/langwell_otg.h
+++ b/include/linux/usb/langwell_otg.h
@@ -150,17 +150,17 @@ struct langwell_otg_timer {
 };
 
 struct langwell_otg {
-	struct otg_transceiver 	otg;
-	struct otg_hsm 		hsm;
-	void __iomem 		*regs;
-	unsigned 		region;
+	struct otg_transceiver	otg;
+	struct otg_hsm		hsm;
+	void __iomem		*regs;
+	unsigned		region;
 	struct pci_driver	*host_ops;
 	struct pci_driver	*client_ops;
 	struct pci_dev		*pdev;
-	struct work_struct 	work;
+	struct work_struct	work;
 	struct workqueue_struct	*qwork;
-	spinlock_t 		lock;
-	spinlock_t 		wq_lock;
+	spinlock_t		lock;
+	spinlock_t		wq_lock;
 };
 
 static inline struct langwell_otg *otg_to_langwell(struct otg_transceiver *otg)
@@ -168,11 +168,4 @@ static inline struct langwell_otg *otg_to_langwell(struct otg_transceiver *otg)
 	return container_of(otg, struct langwell_otg, otg);
 }
 
-#ifdef DEBUG
-#define otg_dbg(fmt, args...) \
-	printk(KERN_DEBUG fmt , ## args)
-#else
-#define otg_dbg(fmt, args...) \
-	do { } while (0)
-#endif /* DEBUG */
 #endif /* __LANGWELL_OTG_H__ */

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux