mfd: intel-lpss: Provide Intel LPSS PM ops structure
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 24 Nov 2023 19:31:28 +0000 (21:31 +0200)
committerLee Jones <lee@kernel.org>
Thu, 7 Dec 2023 13:50:29 +0000 (13:50 +0000)
With the help of EXPORT_NS_GPL_DEV_PM_OPS() and other *_PM_OPS() macros
we may convert PM ops functions to become static. This also takes into
account the PM configuration options such as CONFIG_PM and CONFIG_PM_SLEEP.
This all removes a lot of ugly macros and ifdeffery in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231124200258.3682979-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/intel-lpss-acpi.c
drivers/mfd/intel-lpss-pci.c
drivers/mfd/intel-lpss.c
drivers/mfd/intel-lpss.h

index a9e2d9308a01c08db7fadddf1c8a8b7bba0a9a50..2a83f8678f1d921e085f4748e5b4ed01e100e30e 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/ioport.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
@@ -205,15 +206,13 @@ static void intel_lpss_acpi_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
 }
 
-static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
-
 static struct platform_driver intel_lpss_acpi_driver = {
        .probe = intel_lpss_acpi_probe,
        .remove_new = intel_lpss_acpi_remove,
        .driver = {
                .name = "intel-lpss",
                .acpi_match_table = intel_lpss_acpi_ids,
-               .pm = &intel_lpss_acpi_pm_ops,
+               .pm = pm_ptr(&intel_lpss_pm_ops),
        },
 };
 
index e1d89423daa6a06ca0496d6a69e7ba31f87f776b..8f5e10817a9c56e68ecd671a49fb5e5a62f45d02 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
 
@@ -81,8 +82,6 @@ static void intel_lpss_pci_remove(struct pci_dev *pdev)
        intel_lpss_remove(&pdev->dev);
 }
 
-static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
-
 static const struct property_entry spt_spi_properties[] = {
        PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_SPT_SSP),
        { }
@@ -593,7 +592,7 @@ static struct pci_driver intel_lpss_pci_driver = {
        .probe = intel_lpss_pci_probe,
        .remove = intel_lpss_pci_remove,
        .driver = {
-               .pm = &intel_lpss_pci_pm_ops,
+               .pm = pm_ptr(&intel_lpss_pm_ops),
        },
 };
 
index 4a63703b6da56b13b4283d9ef74c9cce342a3f0c..177915845ba2bec00ca1d67990a3be7103a23877 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/ioport.h>
 #include <linux/mfd/core.h>
 #include <linux/module.h>
+#include <linux/pm.h>
 #include <linux/pm_qos.h>
 #include <linux/pm_runtime.h>
 #include <linux/sprintf.h>
@@ -470,7 +471,6 @@ void intel_lpss_remove(struct device *dev)
 }
 EXPORT_SYMBOL_NS_GPL(intel_lpss_remove, INTEL_LPSS);
 
-#ifdef CONFIG_PM
 static int resume_lpss_device(struct device *dev, void *data)
 {
        if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND))
@@ -479,7 +479,7 @@ static int resume_lpss_device(struct device *dev, void *data)
        return 0;
 }
 
-int intel_lpss_prepare(struct device *dev)
+static int intel_lpss_prepare(struct device *dev)
 {
        /*
         * Resume both child devices before entering system sleep. This
@@ -488,9 +488,8 @@ int intel_lpss_prepare(struct device *dev)
        device_for_each_child_reverse(dev, NULL, resume_lpss_device);
        return 0;
 }
-EXPORT_SYMBOL_NS_GPL(intel_lpss_prepare, INTEL_LPSS);
 
-int intel_lpss_suspend(struct device *dev)
+static int intel_lpss_suspend(struct device *dev)
 {
        struct intel_lpss *lpss = dev_get_drvdata(dev);
        unsigned int i;
@@ -509,9 +508,8 @@ int intel_lpss_suspend(struct device *dev)
 
        return 0;
 }
-EXPORT_SYMBOL_NS_GPL(intel_lpss_suspend, INTEL_LPSS);
 
-int intel_lpss_resume(struct device *dev)
+static int intel_lpss_resume(struct device *dev)
 {
        struct intel_lpss *lpss = dev_get_drvdata(dev);
        unsigned int i;
@@ -524,8 +522,12 @@ int intel_lpss_resume(struct device *dev)
 
        return 0;
 }
-EXPORT_SYMBOL_NS_GPL(intel_lpss_resume, INTEL_LPSS);
-#endif
+
+EXPORT_NS_GPL_DEV_PM_OPS(intel_lpss_pm_ops, INTEL_LPSS) = {
+       .prepare = pm_sleep_ptr(&intel_lpss_prepare),
+       LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume)
+       RUNTIME_PM_OPS(intel_lpss_suspend, intel_lpss_resume, NULL)
+};
 
 static int __init intel_lpss_init(void)
 {
index 062ce95b68b9ade80331f5b0cbb8b977e6ba79fa..c1d72b117ed5e6e27faae391de1f604cf5f4b139 100644 (file)
@@ -30,32 +30,6 @@ int intel_lpss_probe(struct device *dev,
                     const struct intel_lpss_platform_info *info);
 void intel_lpss_remove(struct device *dev);
 
-#ifdef CONFIG_PM
-int intel_lpss_prepare(struct device *dev);
-int intel_lpss_suspend(struct device *dev);
-int intel_lpss_resume(struct device *dev);
-
-#ifdef CONFIG_PM_SLEEP
-#define INTEL_LPSS_SLEEP_PM_OPS                        \
-       .prepare = intel_lpss_prepare,          \
-       SET_LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume)
-#else
-#define INTEL_LPSS_SLEEP_PM_OPS
-#endif
-
-#define INTEL_LPSS_RUNTIME_PM_OPS              \
-       .runtime_suspend = intel_lpss_suspend,  \
-       .runtime_resume = intel_lpss_resume,
-
-#else /* !CONFIG_PM */
-#define INTEL_LPSS_SLEEP_PM_OPS
-#define INTEL_LPSS_RUNTIME_PM_OPS
-#endif /* CONFIG_PM */
-
-#define INTEL_LPSS_PM_OPS(name)                        \
-const struct dev_pm_ops name = {               \
-       INTEL_LPSS_SLEEP_PM_OPS                 \
-       INTEL_LPSS_RUNTIME_PM_OPS               \
-}
+extern const struct dev_pm_ops intel_lpss_pm_ops;
 
 #endif /* __MFD_INTEL_LPSS_H */