mmc: host: sdhci-pltfm: Add suspend and resume hooks to sdhci platform
Colin Cross [Fri, 6 May 2011 04:47:55 +0000 (21:47 -0700)]
Change-Id: I062fbe91d8af14366a92af1a27e9dab49869905c
Signed-off-by: Colin Cross <ccross@android.com>

drivers/mmc/host/sdhci-pltfm.c
drivers/mmc/host/sdhci.h

index 6414efe..1179f1b 100644 (file)
@@ -196,16 +196,42 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister);
 int sdhci_pltfm_suspend(struct platform_device *dev, pm_message_t state)
 {
        struct sdhci_host *host = platform_get_drvdata(dev);
+       int ret;
+
+       ret = sdhci_suspend_host(host, state);
+       if (ret) {
+               dev_err(&dev->dev, "suspend failed, error = %d\n", ret);
+               return ret;
+       }
 
-       return sdhci_suspend_host(host, state);
+       if (host->ops && host->ops->suspend)
+               ret = host->ops->suspend(host, state);
+       if (ret) {
+               dev_err(&dev->dev, "suspend hook failed, error = %d\n", ret);
+               sdhci_resume_host(host);
+       }
+
+       return ret;
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_suspend);
 
 int sdhci_pltfm_resume(struct platform_device *dev)
 {
        struct sdhci_host *host = platform_get_drvdata(dev);
+       int ret = 0;
+
+       if (host->ops && host->ops->resume)
+               ret = host->ops->resume(host);
+       if (ret) {
+               dev_err(&dev->dev, "resume hook failed, error = %d\n", ret);
+               return ret;
+       }
 
-       return sdhci_resume_host(host);
+       ret = sdhci_resume_host(host);
+       if (ret)
+               dev_err(&dev->dev, "resume failed, error = %d\n", ret);
+
+       return ret;
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_resume);
 #endif /* CONFIG_PM */
index 745c42f..40619b7 100644 (file)
@@ -274,6 +274,8 @@ struct sdhci_ops {
        void    (*platform_reset_exit)(struct sdhci_host *host, u8 mask);
        int     (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs);
 
+       int             (*suspend)(struct sdhci_host *host, pm_message_t state);
+       int             (*resume)(struct sdhci_host *host);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS