[PATCH v2 03/25] usb: langwell_otg: use unified otg_notify function.

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

 



This patch adds support to unified otg_notify function instead of private
interface for Intel mid. This patch depends on "usb: otg: add unified
otg_notify function for usb otg event notification".

Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
---
 drivers/usb/otg/langwell_otg.c |   49 ++++++++++++++--------------------------
 1 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
index bdc3ea6..f3bb380 100644
--- a/drivers/usb/otg/langwell_otg.c
+++ b/drivers/usb/otg/langwell_otg.c
@@ -887,21 +887,15 @@ static irqreturn_t otg_irq(int irq, void *_dev)
 	return IRQ_HANDLED;
 }
 
-static int langwell_otg_iotg_notify(struct notifier_block *nb,
-				unsigned long action, void *data)
+static int
+langwell_otg_notify(struct otg_transceiver *otg, enum usb_otg_events event)
 {
 	struct langwell_otg		*lnw = the_transceiver;
-	struct intel_mid_otg_xceiv	*iotg = data;
+	struct intel_mid_otg_xceiv	*iotg = &lnw->iotg;
 	int				flag = 0;
 
-	if (iotg == NULL)
-		return NOTIFY_BAD;
-
-	if (lnw == NULL)
-		return NOTIFY_BAD;
-
-	switch (action) {
-	case MID_OTG_NOTIFY_CONNECT:
+	switch (event) {
+	case USB_OTG_CONNECT:
 		dev_dbg(lnw->dev, "Lnw OTG Notify Connect Event\n");
 		if (iotg->otg.default_a == 1)
 			iotg->hsm.b_conn = 1;
@@ -909,7 +903,7 @@ static int langwell_otg_iotg_notify(struct notifier_block *nb,
 			iotg->hsm.a_conn = 1;
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_DISCONN:
+	case USB_OTG_DISCON:
 		dev_dbg(lnw->dev, "Lnw OTG Notify Disconnect Event\n");
 		if (iotg->otg.default_a == 1)
 			iotg->hsm.b_conn = 0;
@@ -917,7 +911,7 @@ static int langwell_otg_iotg_notify(struct notifier_block *nb,
 			iotg->hsm.a_conn = 0;
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_HSUSPEND:
+	case USB_OTG_HOST_SUSP:
 		dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus suspend Event\n");
 		if (iotg->otg.default_a == 1)
 			iotg->hsm.a_suspend_req = 1;
@@ -925,13 +919,13 @@ static int langwell_otg_iotg_notify(struct notifier_block *nb,
 			iotg->hsm.b_bus_req = 0;
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_HRESUME:
+	case USB_OTG_HOST_RESU:
 		dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus resume Event\n");
 		if (iotg->otg.default_a == 1)
 			iotg->hsm.b_bus_resume = 1;
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_CSUSPEND:
+	case USB_OTG_DEV_SUSP:
 		dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus suspend Event\n");
 		if (iotg->otg.default_a == 1) {
 			if (iotg->hsm.b_bus_suspend_vld == 2) {
@@ -949,37 +943,37 @@ static int langwell_otg_iotg_notify(struct notifier_block *nb,
 			}
 		}
 		break;
-	case MID_OTG_NOTIFY_CRESUME:
+	case USB_OTG_DEV_RESU:
 		dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus resume Event\n");
 		if (iotg->otg.default_a == 0)
 			iotg->hsm.a_bus_suspend = 0;
 		flag = 0;
 		break;
-	case MID_OTG_NOTIFY_HOSTADD:
+	case USB_OTG_HOST_ACTIVE:
 		dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver Add\n");
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_HOSTREMOVE:
+	case USB_OTG_HOST_STOP:
 		dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver remove\n");
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_CLIENTADD:
+	case USB_OTG_DEV_ACTIVE:
 		dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver Add\n");
 		flag = 1;
 		break;
-	case MID_OTG_NOTIFY_CLIENTREMOVE:
+	case USB_OTG_DEV_STOP:
 		dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver remove\n");
 		flag = 1;
 		break;
 	default:
 		dev_dbg(lnw->dev, "Lnw OTG Nofity unknown notify message\n");
-		return NOTIFY_DONE;
+		return -EINVAL;
 	}
 
 	if (flag)
 		langwell_update_transceiver();
 
-	return NOTIFY_OK;
+	return 0;
 }
 
 static void langwell_otg_work(struct work_struct *work)
@@ -2104,6 +2098,7 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 	lnw->iotg.otg.set_power = langwell_otg_set_power;
 	lnw->iotg.otg.set_vbus = langwell_otg_set_vbus;
 	lnw->iotg.otg.start_srp = langwell_otg_start_srp;
+	lnw->iotg.otg.otg_notify = langwell_otg_notify;
 	lnw->iotg.otg.state = OTG_STATE_UNDEFINED;
 
 	if (otg_set_transceiver(&lnw->iotg.otg)) {
@@ -2125,16 +2120,6 @@ static int langwell_otg_probe(struct pci_dev *pdev,
 	}
 
 	init_timer(&lnw->hsm_timer);
-	ATOMIC_INIT_NOTIFIER_HEAD(&lnw->iotg.iotg_notifier);
-
-	lnw->iotg_notifier.notifier_call = langwell_otg_iotg_notify;
-
-	retval = intel_mid_otg_register_notifier(&lnw->iotg,
-						&lnw->iotg_notifier);
-	if (retval) {
-		dev_dbg(lnw->dev, "Failed to register notifier\n");
-		goto err;
-	}
 
 	if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
 				driver_name, lnw) != 0) {
-- 
1.6.0.6

--
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