]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ACPI / LPSS: Consolidate runtime PM and system sleep handling
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 16 Oct 2017 01:29:55 +0000 (03:29 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 24 Oct 2017 11:27:45 +0000 (13:27 +0200)
Move the LPSS-specific code from acpi_lpss_runtime_suspend()
and acpi_lpss_runtime_resume() into separate functions,
acpi_lpss_suspend() and acpi_lpss_resume(), respectively, and
make acpi_lpss_suspend_late() and acpi_lpss_resume_early() use
them too in order to unify the runtime PM and system sleep
handling in the LPSS driver.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/acpi/acpi_lpss.c

index 8ec19e7c7b61b7b794b80d54e7a65af9f68b5f29..04d32bdb5a95b573d3c3cac5d724b86969e574b9 100644 (file)
@@ -716,40 +716,6 @@ static void acpi_lpss_dismiss(struct device *dev)
        acpi_dev_suspend(dev, false);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int acpi_lpss_suspend_late(struct device *dev)
-{
-       struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
-       int ret;
-
-       ret = pm_generic_suspend_late(dev);
-       if (ret)
-               return ret;
-
-       if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
-               acpi_lpss_save_ctx(dev, pdata);
-
-       return acpi_dev_suspend(dev, device_may_wakeup(dev));
-}
-
-static int acpi_lpss_resume_early(struct device *dev)
-{
-       struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
-       int ret;
-
-       ret = acpi_dev_resume(dev);
-       if (ret)
-               return ret;
-
-       acpi_lpss_d3_to_d0_delay(pdata);
-
-       if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
-               acpi_lpss_restore_ctx(dev, pdata);
-
-       return pm_generic_resume_early(dev);
-}
-#endif /* CONFIG_PM_SLEEP */
-
 /* IOSF SB for LPSS island */
 #define LPSS_IOSF_UNIT_LPIOEP          0xA0
 #define LPSS_IOSF_UNIT_LPIO1           0xAB
@@ -835,19 +801,15 @@ static void lpss_iosf_exit_d3_state(void)
        mutex_unlock(&lpss_iosf_mutex);
 }
 
-static int acpi_lpss_runtime_suspend(struct device *dev)
+static int acpi_lpss_suspend(struct device *dev, bool wakeup)
 {
        struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
        int ret;
 
-       ret = pm_generic_runtime_suspend(dev);
-       if (ret)
-               return ret;
-
        if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
                acpi_lpss_save_ctx(dev, pdata);
 
-       ret = acpi_dev_suspend(dev, true);
+       ret = acpi_dev_suspend(dev, wakeup);
 
        /*
         * This call must be last in the sequence, otherwise PMC will return
@@ -860,7 +822,7 @@ static int acpi_lpss_runtime_suspend(struct device *dev)
        return ret;
 }
 
-static int acpi_lpss_runtime_resume(struct device *dev)
+static int acpi_lpss_resume(struct device *dev)
 {
        struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
        int ret;
@@ -881,7 +843,37 @@ static int acpi_lpss_runtime_resume(struct device *dev)
        if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
                acpi_lpss_restore_ctx(dev, pdata);
 
-       return pm_generic_runtime_resume(dev);
+       return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int acpi_lpss_suspend_late(struct device *dev)
+{
+       int ret = pm_generic_suspend_late(dev);
+
+       return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev));
+}
+
+static int acpi_lpss_resume_early(struct device *dev)
+{
+       int ret = acpi_lpss_resume(dev);
+
+       return ret ? ret : pm_generic_resume_early(dev);
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static int acpi_lpss_runtime_suspend(struct device *dev)
+{
+       int ret = pm_generic_runtime_suspend(dev);
+
+       return ret ? ret : acpi_lpss_suspend(dev, true);
+}
+
+static int acpi_lpss_runtime_resume(struct device *dev)
+{
+       int ret = acpi_lpss_resume(dev);
+
+       return ret ? ret : pm_generic_runtime_resume(dev);
 }
 #endif /* CONFIG_PM */