Skip to contentSkip to conversation

mmc: sdhci-pci: move suspend/resume hooks to dev_pm_ops

PATCH In review Manuel Lauss 2 participants 4 messages Nov 1, 2011 – Nov 2, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-pci: move suspend/resume hooks to dev_pm_ops

Move suspend/resume/freeze/thaw hooks from struct pci_driver to dev_pm_ops, mainly to shut up the driver cores' complaints about this driver using both new and legacy PM methods.

---
I've only tested suspend to ram, but it works.

 drivers/mmc/host/sdhci-pci.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pci.c +20 -4
index d833d9c..53bfbe7 100644
@@ -993,7 +993,7 @@ static struct sdhci_ops sdhci_pci_ops = {
 
 #ifdef CONFIG_PM
 
-static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int sdhci_pci_do_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
@@ -1050,8 +1050,9 @@ static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 	return 0;
 }
 
-static int sdhci_pci_resume(struct pci_dev *pdev)
+static int sdhci_pci_resume(struct device *dev)
 {
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
 	int i, ret;
@@ -1085,9 +1086,22 @@ static int sdhci_pci_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static int sdhci_pci_suspend(struct device *dev)
+{
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+	return sdhci_pci_do_suspend(pdev, PMSG_SUSPEND);
+}
+
+static int sdhci_pci_freeze(struct device *dev)
+{
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+	return sdhci_pci_do_suspend(pdev, PMSG_FREEZE);
+}
+
 #else /* CONFIG_PM */
 
 #define sdhci_pci_suspend NULL
+#define sdhci_pci_freeze NULL
 #define sdhci_pci_resume NULL
 
 #endif /* CONFIG_PM */
@@ -1176,6 +1190,10 @@ static int sdhci_pci_runtime_idle(struct device *dev)
 #endif
 
 static const struct dev_pm_ops sdhci_pci_pm_ops = {
+	.suspend = sdhci_pci_suspend,
+	.freeze = sdhci_pci_freeze,
+	.resume = sdhci_pci_resume,
+	.thaw = sdhci_pci_resume,
 	.runtime_suspend = sdhci_pci_runtime_suspend,
 	.runtime_resume = sdhci_pci_runtime_resume,
 	.runtime_idle = sdhci_pci_runtime_idle,
@@ -1428,8 +1446,6 @@ static struct pci_driver sdhci_driver = {
 	.id_table =	pci_ids,
 	.probe =	sdhci_pci_probe,
 	.remove =	__devexit_p(sdhci_pci_remove),
-	.suspend =	sdhci_pci_suspend,
-	.resume	=	sdhci_pci_resume,
 	.driver =	{
 		.pm =   &sdhci_pci_pm_ops
 	},
Signature · 1 line
1.7.7.1
maintainer
#1 lore raw
Quoted 3 lines · Manuel Lauss

Move suspend/resume/freeze/thaw hooks from struct pci_driver to dev_pm_ops, mainly to shut up the driver cores' complaints about this driver using both new and legacy PM methods.

Thanks for picking up on this

Quoted 33 lines

---
I've only tested suspend to ram, but it works.

 drivers/mmc/host/sdhci-pci.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pci.c +3 -2
index d833d9c..53bfbe7 100644
@@ -993,7 +993,7 @@ static struct sdhci_ops sdhci_pci_ops = {
 
 #ifdef CONFIG_PM
 
-static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int sdhci_pci_do_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
@@ -1050,8 +1050,9 @@ static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 	return 0;
 }
 
-static int sdhci_pci_resume(struct pci_dev *pdev)
+static int sdhci_pci_resume(struct device *dev)
 {
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
 	int i, ret;

drivers/mmc/host/sdhci-pci.c static int sdhci_pci_resume(struct pci_dev *pdev) · line 1092

Quoted 7 lines
drivers/mmc/host/sdhci-pci.c +4 -0
@@ -1085,9 +1086,22 @@ static int sdhci_pci_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static int sdhci_pci_suspend(struct device *dev)
+{
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+	return sdhci_pci_do_suspend(pdev, PMSG_SUSPEND);

We need to get rid of state entirely. Unfortunately that means changing sdhci_suspend_host() and all callers

Quoted 16 lines
drivers/mmc/host/sdhci-pci.c +9 -0
+}
+
+static int sdhci_pci_freeze(struct device *dev)
+{
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+	return sdhci_pci_do_suspend(pdev, PMSG_FREEZE);
+}
+
 #else /* CONFIG_PM */
 
 #define sdhci_pci_suspend NULL
+#define sdhci_pci_freeze NULL
 #define sdhci_pci_resume NULL
 
 #endif /* CONFIG_PM */

drivers/mmc/host/sdhci-pci.c static int sdhci_pci_runtime_idle(struct device *dev) · line 1196

Quoted 7 lines
drivers/mmc/host/sdhci-pci.c +4 -0
@@ -1176,6 +1190,10 @@ static int sdhci_pci_runtime_idle(struct device *dev)
 #endif
 
 static const struct dev_pm_ops sdhci_pci_pm_ops = {
+	.suspend = sdhci_pci_suspend,
+	.freeze = sdhci_pci_freeze,
+	.resume = sdhci_pci_resume,
+	.thaw = sdhci_pci_resume,

freeze and thaw are not needed

Quoted 12 lines
drivers/mmc/host/sdhci-pci.c +0 -2
 	.runtime_suspend = sdhci_pci_runtime_suspend,
 	.runtime_resume = sdhci_pci_runtime_resume,
 	.runtime_idle = sdhci_pci_runtime_idle,
@@ -1428,8 +1446,6 @@ static struct pci_driver sdhci_driver = {
 	.id_table =	pci_ids,
 	.probe =	sdhci_pci_probe,
 	.remove =	__devexit_p(sdhci_pci_remove),
-	.suspend =	sdhci_pci_suspend,
-	.resume	=	sdhci_pci_resume,
 	.driver =	{
 		.pm =   &sdhci_pci_pm_ops
 	},
maintainer
#2 lore raw
Quoted 6 lines · Adrian Hunter
Quoted 3 lines · Manuel Lauss

Move suspend/resume/freeze/thaw hooks from struct pci_driver to dev_pm_ops, mainly to shut up the driver cores' complaints about this driver using both new and legacy PM methods.

Thanks for picking up on this

Also use to_pci_dev(dev) instead of container_of(dev, struct pci_dev, dev)

Quoted 85 lines
Quoted 34 lines

---
I've only tested suspend to ram, but it works.

 drivers/mmc/host/sdhci-pci.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pci.c +3 -2
index d833d9c..53bfbe7 100644
@@ -993,7 +993,7 @@ static struct sdhci_ops sdhci_pci_ops = {
 
 #ifdef CONFIG_PM
 
-static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int sdhci_pci_do_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
@@ -1050,8 +1050,9 @@ static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 	return 0;
 }
 
-static int sdhci_pci_resume(struct pci_dev *pdev)
+static int sdhci_pci_resume(struct device *dev)
 {
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
 	int i, ret;

drivers/mmc/host/sdhci-pci.c static int sdhci_pci_resume(struct pci_dev *pdev) · line 1092

Quoted 7 lines
drivers/mmc/host/sdhci-pci.c +4 -0
@@ -1085,9 +1086,22 @@ static int sdhci_pci_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static int sdhci_pci_suspend(struct device *dev)
+{
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+	return sdhci_pci_do_suspend(pdev, PMSG_SUSPEND);

We need to get rid of state entirely. Unfortunately that means changing sdhci_suspend_host() and all callers

Quoted 16 lines
drivers/mmc/host/sdhci-pci.c +9 -0
+}
+
+static int sdhci_pci_freeze(struct device *dev)
+{
+	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+	return sdhci_pci_do_suspend(pdev, PMSG_FREEZE);
+}
+
 #else /* CONFIG_PM */
 
 #define sdhci_pci_suspend NULL
+#define sdhci_pci_freeze NULL
 #define sdhci_pci_resume NULL
 
 #endif /* CONFIG_PM */

drivers/mmc/host/sdhci-pci.c static int sdhci_pci_runtime_idle(struct device *dev) · line 1196

Quoted 7 lines
drivers/mmc/host/sdhci-pci.c +4 -0
@@ -1176,6 +1190,10 @@ static int sdhci_pci_runtime_idle(struct device *dev)
 #endif
 
 static const struct dev_pm_ops sdhci_pci_pm_ops = {
+	.suspend = sdhci_pci_suspend,
+	.freeze = sdhci_pci_freeze,
+	.resume = sdhci_pci_resume,
+	.thaw = sdhci_pci_resume,

freeze and thaw are not needed

Quoted 12 lines
drivers/mmc/host/sdhci-pci.c +0 -2
 	.runtime_suspend = sdhci_pci_runtime_suspend,
 	.runtime_resume = sdhci_pci_runtime_resume,
 	.runtime_idle = sdhci_pci_runtime_idle,
@@ -1428,8 +1446,6 @@ static struct pci_driver sdhci_driver = {
 	.id_table =	pci_ids,
 	.probe =	sdhci_pci_probe,
 	.remove =	__devexit_p(sdhci_pci_remove),
-	.suspend =	sdhci_pci_suspend,
-	.resume	=	sdhci_pci_resume,
 	.driver =	{
 		.pm =   &sdhci_pci_pm_ops
 	},
#3 lore raw
In reply to Adrian Hunter

Hi Adrian,

Quoted 4 lines · Adrian Hunter
Quoted 3 lines · Manuel Lauss

Move suspend/resume/freeze/thaw hooks from struct pci_driver to dev_pm_ops, mainly to shut up the driver cores' complaints about this driver using both new and legacy PM methods.

[...]

Quoted 7 lines

drivers/mmc/host/sdhci-pci.c static int sdhci_pci_resume(struct pci_dev *pdev) · line 1092

Quoted 4 lines
drivers/mmc/host/sdhci-pci.c +4 -0
+static int sdhci_pci_suspend(struct device *dev)
+{
+     struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+     return sdhci_pci_do_suspend(pdev, PMSG_SUSPEND);

We need to get rid of state entirely.  Unfortunately that means changing sdhci_suspend_host() and all callers

This first attempt was a quick hack to get rid of the annoying messages. I'll cook up something more thorough, hang on.

Thanks!
Manuel Lauss