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 02/12] arm: change sa1111 platform and bus power management to use dev_pm_ops
Date: Mon, 10 Feb 2014 09:12:25 -0700 [thread overview]
Message-ID: <9946f14a5837560d5aa83bf3501685365a1aa759.1392040067.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 sa1111 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/sa1111.c | 88 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 72 insertions(+), 16 deletions(-)
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index e57d7e5..db017b2 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -872,7 +872,7 @@ struct sa1111_save_data {
#ifdef CONFIG_PM
-static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
+static int __sa1111_suspend(struct platform_device *dev, pm_message_t state)
{
struct sa1111 *sachip = platform_get_drvdata(dev);
struct sa1111_save_data *save;
@@ -928,6 +928,21 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
return 0;
}
+static int sa1111_suspend(struct device *dev)
+{
+ return __sa1111_suspend(to_platform_device(dev), PMSG_SUSPEND);
+}
+
+static int sa1111_freeze(struct device *dev)
+{
+ return __sa1111_suspend(to_platform_device(dev), PMSG_FREEZE);
+}
+
+static int sa1111_poweroff(struct device *dev)
+{
+ return __sa1111_suspend(to_platform_device(dev), PMSG_HIBERNATE);
+}
+
/*
* sa1111_resume - Restore the SA1111 device state.
* @dev: device to restore
@@ -937,7 +952,7 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
* restored by their respective drivers, and must be called
* via LDM after this function.
*/
-static int sa1111_resume(struct platform_device *dev)
+static int __sa1111_resume(struct platform_device *dev)
{
struct sa1111 *sachip = platform_get_drvdata(dev);
struct sa1111_save_data *save;
@@ -1005,9 +1020,10 @@ static int sa1111_resume(struct platform_device *dev)
return 0;
}
-#else
-#define sa1111_suspend NULL
-#define sa1111_resume NULL
+static int sa1111_resume(struct device *dev)
+{
+ return __sa1111_resume(to_platform_device(dev));
+}
#endif
static int sa1111_probe(struct platform_device *pdev)
@@ -1041,6 +1057,18 @@ static int sa1111_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM
+static const struct dev_pm_ops sa1111_dev_pm_ops = {
+ .suspend = sa1111_suspend,
+ .resume = sa1111_resume,
+ /* Hibernate hooks */
+ .freeze = sa1111_freeze,
+ .thaw = sa1111_resume,
+ .poweroff = sa1111_poweroff,
+ .restore = sa1111_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
@@ -1053,11 +1081,12 @@ static int sa1111_remove(struct platform_device *pdev)
static struct platform_driver sa1111_device_driver = {
.probe = sa1111_probe,
.remove = sa1111_remove,
- .suspend = sa1111_suspend,
- .resume = sa1111_resume,
.driver = {
.name = "sa1111",
.owner = THIS_MODULE,
+#ifdef CONFIG_PM
+ .pm = &sa1111_dev_pm_ops,
+#endif
},
};
@@ -1297,26 +1326,44 @@ static int sa1111_match(struct device *_dev, struct device_driver *_drv)
return dev->devid & drv->devid;
}
-static int sa1111_bus_suspend(struct device *dev, pm_message_t state)
+static int __sa1111_bus_suspend(struct device *dev, pm_message_t state)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_driver *drv = SA1111_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(sadev, state);
- return ret;
+ return drv->suspend(sadev, state);
+ return 0;
+}
+
+static int sa1111_bus_suspend(struct device *dev)
+{
+ return __sa1111_bus_suspend(dev, PMSG_SUSPEND);
+}
+
+static int sa1111_bus_freeze(struct device *dev)
+{
+ return __sa1111_bus_suspend(dev, PMSG_FREEZE);
+}
+
+static int sa1111_bus_poweroff(struct device *dev)
+{
+ return __sa1111_bus_suspend(dev, PMSG_HIBERNATE);
}
static int sa1111_bus_resume(struct device *dev)
{
struct sa1111_dev *sadev = SA1111_DEV(dev);
struct sa1111_driver *drv = SA1111_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(sadev);
- return ret;
+ return drv->resume(sadev);
+ return 0;
}
static void sa1111_bus_shutdown(struct device *dev)
@@ -1349,14 +1396,23 @@ static int sa1111_bus_remove(struct device *dev)
return ret;
}
+static const struct dev_pm_ops sa1111_bus_dev_pm_ops = {
+ .suspend = sa1111_bus_suspend,
+ .resume = sa1111_bus_resume,
+ /* Hibernate hooks */
+ .freeze = sa1111_bus_freeze,
+ .thaw = sa1111_bus_resume,
+ .poweroff = sa1111_bus_poweroff,
+ .restore = sa1111_bus_resume,
+};
+
struct bus_type sa1111_bus_type = {
.name = "sa1111-rab",
.match = sa1111_match,
.probe = sa1111_bus_probe,
.remove = sa1111_bus_remove,
- .suspend = sa1111_bus_suspend,
- .resume = sa1111_bus_resume,
.shutdown = sa1111_bus_shutdown,
+ .pm = &sa1111_bus_dev_pm_ops,
};
EXPORT_SYMBOL(sa1111_bus_type);
--
1.7.10.4
next prev parent 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 ` [RFT][PATCH 01/12] arm: change locomo platform and bus " Shuah Khan
2014-02-10 16:12 ` Shuah Khan [this message]
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=9946f14a5837560d5aa83bf3501685365a1aa759.1392040067.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).