linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shuah Khan <shuah.kh@samsung.com>
To: rjw@rjwysocki.net, linux@arm.linux.org.uk
Cc: Shuah Khan <shuah.kh@samsung.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, shuahkhan@gmail.com
Subject: [RFT][PATCH 01/12] arm: change locomo platform and bus power management to use dev_pm_ops
Date: Mon, 10 Feb 2014 09:12:24 -0700	[thread overview]
Message-ID: <7483e110cf0e8938e4df73dbf7f9e8da1315e9af.1392040066.git.shuah.kh@samsung.com> (raw)
In-Reply-To: <cover.1392040064.git.shuah.kh@samsung.com>
In-Reply-To: <cover.1392040064.git.shuah.kh@samsung.com>

Change locomo platform and bus drivers 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>
---
 arch/arm/common/locomo.c |   93 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 78 insertions(+), 15 deletions(-)

diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index b55c362..a48effb 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -272,7 +272,7 @@ struct locomo_save_data {
 	u16	LCM_SPIMD;
 };
 
-static int locomo_suspend(struct platform_device *dev, pm_message_t state)
+static int __locomo_suspend(struct platform_device *dev, pm_message_t state)
 {
 	struct locomo *lchip = platform_get_drvdata(dev);
 	struct locomo_save_data *save;
@@ -316,7 +316,22 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state)
 	return 0;
 }
 
-static int locomo_resume(struct platform_device *dev)
+static int locomo_suspend(struct device *dev)
+{
+	 return __locomo_suspend(to_platform_device(dev), PMSG_SUSPEND);
+}
+
+static int locomo_freeze(struct device *dev)
+{
+	 return __locomo_suspend(to_platform_device(dev), PMSG_FREEZE);
+}
+
+static int locomo_poweroff(struct device *dev)
+{
+	 return __locomo_suspend(to_platform_device(dev), PMSG_HIBERNATE);
+}
+
+static int __locomo_resume(struct platform_device *dev)
 {
 	struct locomo *lchip = platform_get_drvdata(dev);
 	struct locomo_save_data *save;
@@ -351,6 +366,11 @@ static int locomo_resume(struct platform_device *dev)
 
 	return 0;
 }
+
+static int locomo_resume(struct device *dev)
+{
+	 return __locomo_resume(to_platform_device(dev));
+}
 #endif
 
 
@@ -510,6 +530,18 @@ static int locomo_remove(struct platform_device *dev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static const struct dev_pm_ops locomo_dev_pm_ops = {
+	.suspend = locomo_suspend,
+	.resume = locomo_resume,
+	/* Hibernate hooks */
+	.freeze = locomo_freeze,
+	.thaw = locomo_resume,
+	.poweroff = locomo_poweroff,
+	.restore = locomo_resume,
+};
+#endif
+
 /*
  *	Not sure if this should be on the system bus or not yet.
  *	We really want some way to register a system device at
@@ -519,12 +551,11 @@ static int locomo_remove(struct platform_device *dev)
 static struct platform_driver locomo_device_driver = {
 	.probe		= locomo_probe,
 	.remove		= locomo_remove,
-#ifdef CONFIG_PM
-	.suspend	= locomo_suspend,
-	.resume		= locomo_resume,
-#endif
 	.driver		= {
 		.name	= "locomo",
+#ifdef CONFIG_PM
+		.pm	= &locomo_dev_pm_ops,
+#endif
 	},
 };
 
@@ -826,26 +857,45 @@ static int locomo_match(struct device *_dev, struct device_driver *_drv)
 	return dev->devid == drv->devid;
 }
 
-static int locomo_bus_suspend(struct device *dev, pm_message_t state)
+static int __locomo_bus_suspend(struct device *dev, pm_message_t state)
 {
 	struct locomo_dev *ldev = LOCOMO_DEV(dev);
 	struct locomo_driver *drv = LOCOMO_DRV(dev->driver);
-	int ret = 0;
+
+	if (drv && drv->drv.pm && drv->drv.pm->suspend)
+		return  drv->drv.pm->suspend(dev);
 
 	if (drv && drv->suspend)
-		ret = drv->suspend(ldev, state);
-	return ret;
+		return	drv->suspend(ldev, state);
+	return 0;
+}
+
+static int locomo_bus_suspend(struct device *dev)
+{
+	return	__locomo_bus_suspend(dev, PMSG_SUSPEND);
+}
+
+static int locomo_bus_freeze(struct device *dev)
+{
+	return	__locomo_bus_suspend(dev, PMSG_FREEZE);
+}
+
+static int locomo_bus_poweroff(struct device *dev)
+{
+	return	__locomo_bus_suspend(dev, PMSG_HIBERNATE);
 }
 
 static int locomo_bus_resume(struct device *dev)
 {
 	struct locomo_dev *ldev = LOCOMO_DEV(dev);
 	struct locomo_driver *drv = LOCOMO_DRV(dev->driver);
-	int ret = 0;
+
+	if (drv && drv->drv.pm && drv->drv.pm->resume)
+		return	drv->drv.pm->resume(dev);
 
 	if (drv && drv->resume)
-		ret = drv->resume(ldev);
-	return ret;
+		return	drv->resume(ldev);
+	return 0;
 }
 
 static int locomo_bus_probe(struct device *dev)
@@ -870,13 +920,26 @@ static int locomo_bus_remove(struct device *dev)
 	return ret;
 }
 
+#ifdef CONFIG_PM
+static const struct dev_pm_ops locomo_bus_dev_pm_ops = {
+	.suspend = locomo_bus_suspend,
+	.resume = locomo_bus_resume,
+	/* Hibernate hooks */
+	.freeze = locomo_bus_freeze,
+	.thaw = locomo_bus_resume,
+	.poweroff = locomo_bus_poweroff,
+	.restore = locomo_bus_resume,
+};
+#endif
+
 struct bus_type locomo_bus_type = {
 	.name		= "locomo-bus",
 	.match		= locomo_match,
 	.probe		= locomo_bus_probe,
 	.remove		= locomo_bus_remove,
-	.suspend	= locomo_bus_suspend,
-	.resume		= locomo_bus_resume,
+#ifdef CONFIG_PM
+	.pm		= &locomo_bus_dev_pm_ops,
+#endif
 };
 
 int locomo_driver_register(struct locomo_driver *driver)
-- 
1.7.10.4


  reply	other threads:[~2014-02-10 16:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-10 16:12 [RFT][PATCH 00/12] change drivers power management to use dev_pm_ops Shuah Khan
2014-02-10 16:12 ` Shuah Khan [this message]
2014-02-10 16:12 ` [RFT][PATCH 02/12] arm: change sa1111 platform and bus " Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 03/12] arm: change scoop platform " Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 04/12] drivers/macintosh/adb: change " Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 05/12] mmc: change au1xmmc " Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 06/12] mmc: change bfin_sdh " Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 07/12] isa: change isa bus " Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 08/12] mmc: change cb710-mmc platform " Shuah Khan
2014-02-10 23:49   ` Michał Mirosław
2014-02-11 15:38     ` Shuah Khan
2014-02-10 16:12 ` [RFT][PATCH 09/12] mmc: change msm_sdcc " Shuah Khan
2014-02-10 16:15 ` [RFT][PATCH 10/12] mmc: change tmio_mmc " Shuah Khan
2014-02-10 16:15 ` [RFT][PATCH 11/12] drivers/pcmcia: change ds driver " Shuah Khan
2014-02-10 16:15 ` [RFT][PATCH 12/12] drivers/s390/crypto: change ap_bus " Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7483e110cf0e8938e4df73dbf7f9e8da1315e9af.1392040066.git.shuah.kh@samsung.com \
    --to=shuah.kh@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=rjw@rjwysocki.net \
    --cc=shuahkhan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).