From: Dinh Nguyen <dingu...@altera.com>

Move suspend/resume code to common platform code.

Signed-off-by: Dinh Nguyen <dingu...@altera.com>
---
 drivers/usb/dwc2/core.h     |    6 ++++++
 drivers/usb/dwc2/gadget.c   |    4 ++--
 drivers/usb/dwc2/platform.c |   23 +++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index b86673c..c0a895b 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -960,12 +960,18 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 #if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
 extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
 extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
 irqreturn_t s3c_hsotg_irq(int irq, void *pw);
 #else
 static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
+static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+{ return 0; }
 static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
 static inline irqreturn_t s3c_hsotg_irq(int irq, void *pw)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index dbcdee0..281b33a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3561,7 +3561,7 @@ int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
        return 0;
 }
 
-static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
+int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
 {
        unsigned long flags;
        int ret = 0;
@@ -3591,7 +3591,7 @@ static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
        return ret;
 }
 
-static int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
+int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
 {
        unsigned long flags;
        int ret = 0;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 4898268..e0a4e0d 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -202,6 +202,27 @@ static int dwc2_driver_probe(struct platform_device *dev)
        return retval;
 }
 
+static int dwc2_suspend(struct platform_device *dev, pm_message_t state)
+{
+       struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+       int ret = 0;
+
+       if (dwc2_is_device_mode(dwc2))
+               ret = s3c_hsotg_suspend(dwc2);
+       return ret;
+}
+
+static int dwc2_resume(struct platform_device *dev)
+{
+       struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+       int ret = 0;
+
+       if (dwc2_is_device_mode(dwc2))
+               ret = s3c_hsotg_resume(dwc2);
+
+       return ret;
+}
+
 static struct platform_driver dwc2_platform_driver = {
        .driver = {
                .name = dwc2_driver_name,
@@ -209,6 +230,8 @@ static struct platform_driver dwc2_platform_driver = {
        },
        .probe = dwc2_driver_probe,
        .remove = dwc2_driver_remove,
+       .suspend = dwc2_suspend,
+       .resume = dwc2_resume,
 };
 
 module_platform_driver(dwc2_platform_driver);
-- 
1.7.9.5

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

Reply via email to