[PATCH v2 16/25] usb: ehci-intel-mid-pci: add transceiver driver interface for runtime pm

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

 



This patch adds transceiver driver interface for runtime pm, in order to
support OTG case.

Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
---
 drivers/usb/host/ehci-intel-mid-pci.c |   47 ++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-intel-mid-pci.c b/drivers/usb/host/ehci-intel-mid-pci.c
index b05bc8a..9c9160b 100644
--- a/drivers/usb/host/ehci-intel-mid-pci.c
+++ b/drivers/usb/host/ehci-intel-mid-pci.c
@@ -144,18 +144,61 @@ static int ehci_mid_stop_host(struct intel_mid_otg_xceiv *iotg)
 	return 0;
 }
 
+#ifdef CONFIG_PM_RUNTIME
+static int ehci_mid_runtime_suspend_host(struct intel_mid_otg_xceiv *iotg)
+{
+	int		retval;
+
+	if (iotg == NULL)
+		return -EINVAL;
+
+	if (ehci_otg_driver.driver.pm == NULL)
+		return -EINVAL;
+
+	retval = ehci_otg_driver.driver.pm->runtime_suspend(iotg->otg.dev);
+	if (retval)
+		dev_warn(iotg->otg.dev, "runtime suspend failed\n");
+
+	return retval;
+}
+
+static int ehci_mid_runtime_resume_host(struct intel_mid_otg_xceiv *iotg)
+{
+	int		retval;
+
+	if (iotg == NULL)
+		return -EINVAL;
+
+	if (ehci_otg_driver.driver.pm == NULL)
+		return -EINVAL;
+
+	retval = ehci_otg_driver.driver.pm->runtime_resume(iotg->otg.dev);
+	if (retval)
+		dev_warn(iotg->otg.dev, "runtime suspend failed\n");
+
+	return retval;
+}
+#else
+
+#define ehci_mid_runtime_suspend_host NULL
+#define ehci_mid_runtime_resume_host NULL
+
+#endif
+
 static int intel_mid_ehci_driver_register(struct pci_driver *host_driver)
 {
 	struct otg_transceiver		*otg;
 	struct intel_mid_otg_xceiv	*iotg;
 
 	otg = otg_get_transceiver();
-	if (otg == NULL)
+	if (otg == NULL || host_driver == NULL)
 		return -EINVAL;
 
 	iotg = otg_to_mid_xceiv(otg);
 	iotg->start_host = ehci_mid_start_host;
 	iotg->stop_host = ehci_mid_stop_host;
+	iotg->runtime_suspend_host = ehci_mid_runtime_suspend_host;
+	iotg->runtime_resume_host = ehci_mid_runtime_resume_host;
 
 	/* notify host driver is registered */
 	atomic_notifier_call_chain(&iotg->iotg_notifier,
@@ -178,6 +221,8 @@ static void intel_mid_ehci_driver_unregister(struct pci_driver *host_driver)
 	iotg = otg_to_mid_xceiv(otg);
 	iotg->start_host = NULL;
 	iotg->stop_host = NULL;
+	iotg->runtime_suspend_host = NULL;
+	iotg->runtime_resume_host = NULL;
 
 	/* notify host driver is unregistered */
 	atomic_notifier_call_chain(&iotg->iotg_notifier,
-- 
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