diff mbox

[RFT,11/12] drivers/pcmcia: change ds driver power management to use dev_pm_ops

Message ID 4159bb4e4aa13212b1eac2be7e911ed18451ec9c.1392040068.git.shuah.kh@samsung.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Shuah Khan Feb. 10, 2014, 4:15 p.m. UTC
Change ds driver to register pm ops using dev_pm_ops instead of legacy
pm_ops. .pm hooks call existing legacy suspend and resume interfaces
by passing in the right pm state.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
---
 drivers/pcmcia/ds.c |   36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 757119b..2979323 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -962,7 +962,10 @@  static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
 
 /************************ runtime PM support ***************************/
 
-static int pcmcia_dev_suspend(struct device *dev, pm_message_t state);
+static int __pcmcia_dev_suspend(struct device *dev, pm_message_t state);
+static int pcmcia_dev_suspend(struct device *dev);
+static int pcmcia_dev_poweroff(struct device *dev);
+static int pcmcia_dev_freeze(struct device *dev);
 static int pcmcia_dev_resume(struct device *dev);
 
 static int runtime_suspend(struct device *dev)
@@ -970,7 +973,7 @@  static int runtime_suspend(struct device *dev)
 	int rc;
 
 	device_lock(dev);
-	rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND);
+	rc = __pcmcia_dev_suspend(dev, PMSG_SUSPEND);
 	device_unlock(dev);
 	return rc;
 }
@@ -1120,7 +1123,22 @@  ATTRIBUTE_GROUPS(pcmcia_dev);
 
 /* PM support, also needed for reset */
 
-static int pcmcia_dev_suspend(struct device *dev, pm_message_t state)
+static int pcmcia_dev_suspend(struct device *dev)
+{
+	return __pcmcia_dev_suspend(dev, PMSG_SUSPEND);
+}
+
+static int pcmcia_dev_poweroff(struct device *dev)
+{
+	return __pcmcia_dev_suspend(dev, PMSG_HIBERNATE);
+}
+
+static int pcmcia_dev_freeze(struct device *dev)
+{
+	return __pcmcia_dev_suspend(dev, PMSG_FREEZE);
+}
+
+static int __pcmcia_dev_suspend(struct device *dev, pm_message_t state)
 {
 	struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
 	struct pcmcia_driver *p_drv = NULL;
@@ -1397,6 +1415,15 @@  static struct class_interface pcmcia_bus_interface __refdata = {
 	.remove_dev = &pcmcia_bus_remove_socket,
 };
 
+static const struct dev_pm_ops pcmcia_bus_dev_pm_ops = {
+	.suspend = pcmcia_dev_suspend,
+	.resume = pcmcia_dev_resume,
+	/* Hibernate callbacks */
+	.freeze = pcmcia_dev_freeze,
+	.thaw = pcmcia_dev_resume,
+	.poweroff = pcmcia_dev_poweroff,
+	.restore = pcmcia_dev_resume,
+};
 
 struct bus_type pcmcia_bus_type = {
 	.name = "pcmcia",
@@ -1405,8 +1432,7 @@  struct bus_type pcmcia_bus_type = {
 	.dev_groups = pcmcia_dev_groups,
 	.probe = pcmcia_device_probe,
 	.remove = pcmcia_device_remove,
-	.suspend = pcmcia_dev_suspend,
-	.resume = pcmcia_dev_resume,
+	.pm = &pcmcia_bus_dev_pm_ops,
 };