Skip to contentSkip to conversation

mmc: sdhci-s3c: Use CONFIG_PM_SLEEP to ifdef system suspend

PATCH In review Mark Brown 3 participants 6 messages Dec 30, 2011 – Jan 2, 2012

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 mmc: sdhci-s3c: Use CONFIG_PM_SLEEP to ifdef system suspend

This matches current best practice as one can have runtime PM enabled without system sleep and CONFIG_PM is defined for both.

---
 drivers/mmc/host/sdhci-s3c.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-s3c.c +5 -4
index 1af756e..df066b5 100644
@@ -20,6 +20,7 @@
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
+#include <linux/pm.h>
 
 #include <linux/mmc/host.h>
 
@@ -620,8 +621,7 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int sdhci_s3c_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -635,10 +635,11 @@ static int sdhci_s3c_resume(struct device *dev)
 
 	return sdhci_resume_host(host);
 }
+#endif
 
+#ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
-	.suspend	= sdhci_s3c_suspend,
-	.resume		= sdhci_s3c_resume,
+	SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
 };
 
 #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
Signature · 1 line
1.7.7.3
author
#1 lore raw

PATCH 2/2 mmc: sdhci-s3c: Enable runtime power management

Since most of the work is already done by the core we just need to add runtime suspend methods and tell the PM core that runtime PM is enabled for this device.

---
 drivers/mmc/host/sdhci-s3c.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-s3c.c +28 -0
index df066b5..cf7ae1e 100644
@@ -21,6 +21,7 @@
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/pm.h>
+#include <linux/pm_runtime.h>
 
 #include <linux/mmc/host.h>
 
@@ -545,6 +546,11 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 	if (pdata->host_caps)
 		host->mmc->caps |= pdata->host_caps;
 
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_suspend_ignore_children(&pdev->dev, 1);
+
 	ret = sdhci_add_host(host);
 	if (ret) {
 		dev_err(dev, "sdhci_add_host() failed\n");
@@ -564,6 +570,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 
  err_add_host:
 	release_resource(sc->ioarea);
+	pm_runtime_forbid(&pdev->dev);
+	pm_runtime_get_noresume(&pdev->dev);
 	kfree(sc->ioarea);
 
  err_req_regs:
@@ -602,6 +610,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 
 	sdhci_remove_host(host, 1);
 
+	pm_runtime_disable(&pdev->dev);
+
 	for (ptr = 0; ptr < 3; ptr++) {
 		if (sc->clk_bus[ptr]) {
 			clk_disable(sc->clk_bus[ptr]);
@@ -637,9 +647,27 @@ static int sdhci_s3c_resume(struct device *dev)
 }
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
+static int sdhci_s3c_runtime_suspend(struct device *dev)
+{
+	struct sdhci_host *host = dev_get_drvdata(dev);
+
+	return sdhci_runtime_suspend_host(host);
+}
+
+static int sdhci_s3c_runtime_resume(struct device *dev)
+{
+	struct sdhci_host *host = dev_get_drvdata(dev);
+
+	return sdhci_runtime_resume_host(host);
+}
+#endif
+
 #ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
 	SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
+	SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
+			   NULL)
 };
 
 #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
Signature · 1 line
1.7.7.3
maintainer
#2 lore raw
In reply to Mark Brown

Hi Mark.

Quoted 13 lines · Mark Brown

This matches current best practice as one can have runtime PM enabled without system sleep and CONFIG_PM is defined for both.

---
 drivers/mmc/host/sdhci-s3c.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-s3c.c +0 -0
index 1af756e..df066b5 100644

drivers/mmc/host/sdhci-s3c.c line 23

Quoted 4 lines
drivers/mmc/host/sdhci-s3c.c +1 -0
@@ -20,6 +20,7 @@
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
+#include <linux/pm.h>

I think this include is unnecessary.

Thanks,
Jaehoon Chung

Quoted 27 lines
drivers/mmc/host/sdhci-s3c.c +4 -4
 #include <linux/mmc/host.h>
 
@@ -620,8 +621,7 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int sdhci_s3c_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -635,10 +635,11 @@ static int sdhci_s3c_resume(struct device *dev)
 
 	return sdhci_resume_host(host);
 }
+#endif
 
+#ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
-	.suspend	= sdhci_s3c_suspend,
-	.resume		= sdhci_s3c_resume,
+	SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
 };
 
 #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
author
#3 lore raw
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Mark Brown

+#include <linux/pm.h>

I think this include is unnecessary.

I think you are wrong. What makes you say that you think it is not needed?

Quoted 5 lines

drivers/mmc/host/sdhci-s3c.c static int sdhci_s3c_resume(struct device *dev) · line 642

Quoted 5 lines
drivers/mmc/host/sdhci-s3c.c +2 -2
+#ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
-	.suspend	= sdhci_s3c_suspend,
-	.resume		= sdhci_s3c_resume,
+	SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)

Note that above.

#4 lore raw

2012/1/2 Mark Brown <[email protected]>:

Quoted 9 lines · Jaehoon Chung
Quoted 5 lines · Mark Brown
Quoted 2 lines

+#include <linux/pm.h>

I think this include is unnecessary.

I think you are wrong.  What makes you say that you think it is not needed?

If that didn't include,,what's happen?
I think that is already included...Anyway..this patch looks fine to me.. (if use with your patch[2/2]..)

Thanks,
Jaehoon Chung

Quoted 12 lines
Quoted 6 lines
Quoted 6 lines

+#ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
-   .suspend        = sdhci_s3c_suspend,
-   .resume         = sdhci_s3c_resume,
+   SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)

Note that above.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

author
#5 lore raw
Quoted 10 lines · Jae hoon Chung

2012/1/2 Mark Brown <[email protected]>:

Quoted 7 lines
Quoted 4 lines · Mark Brown
Quoted 2 lines

+#include <linux/pm.h>

I think this include is unnecessary.

I think you are wrong.  What makes you say that you think it is not needed?

If that didn't include,,what's happen?

The code won't compile as we're relying on a macro defined in the header.

Quoted 2 lines

I think that is already included...Anyway..this patch looks fine to me.. (if use with your patch[2/2]..)

It's not included directly (or indirectly as far as I remember).