Skip to content

Commit fd58bb8

Browse files
andy-shevlag-linaro
authored andcommitted
mfd: intel-lpss: Provide Intel LPSS PM ops structure
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 24ee97a commit fd58bb8

File tree

4 files changed

+15
-41
lines changed

4 files changed

+15
-41
lines changed

drivers/mfd/intel-lpss-acpi.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/ioport.h>
1414
#include <linux/mod_devicetable.h>
1515
#include <linux/module.h>
16+
#include <linux/pm.h>
1617
#include <linux/pm_runtime.h>
1718
#include <linux/platform_device.h>
1819
#include <linux/property.h>
@@ -205,15 +206,13 @@ static void intel_lpss_acpi_remove(struct platform_device *pdev)
205206
pm_runtime_disable(&pdev->dev);
206207
}
207208

208-
static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
209-
210209
static struct platform_driver intel_lpss_acpi_driver = {
211210
.probe = intel_lpss_acpi_probe,
212211
.remove_new = intel_lpss_acpi_remove,
213212
.driver = {
214213
.name = "intel-lpss",
215214
.acpi_match_table = intel_lpss_acpi_ids,
216-
.pm = &intel_lpss_acpi_pm_ops,
215+
.pm = pm_ptr(&intel_lpss_pm_ops),
217216
},
218217
};
219218

drivers/mfd/intel-lpss-pci.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/mod_devicetable.h>
1414
#include <linux/module.h>
1515
#include <linux/pci.h>
16+
#include <linux/pm.h>
1617
#include <linux/pm_runtime.h>
1718
#include <linux/property.h>
1819

@@ -81,8 +82,6 @@ static void intel_lpss_pci_remove(struct pci_dev *pdev)
8182
intel_lpss_remove(&pdev->dev);
8283
}
8384

84-
static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
85-
8685
static const struct property_entry spt_spi_properties[] = {
8786
PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_SPT_SSP),
8887
{ }
@@ -593,7 +592,7 @@ static struct pci_driver intel_lpss_pci_driver = {
593592
.probe = intel_lpss_pci_probe,
594593
.remove = intel_lpss_pci_remove,
595594
.driver = {
596-
.pm = &intel_lpss_pci_pm_ops,
595+
.pm = pm_ptr(&intel_lpss_pm_ops),
597596
},
598597
};
599598

drivers/mfd/intel-lpss.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/ioport.h>
2525
#include <linux/mfd/core.h>
2626
#include <linux/module.h>
27+
#include <linux/pm.h>
2728
#include <linux/pm_qos.h>
2829
#include <linux/pm_runtime.h>
2930
#include <linux/sprintf.h>
@@ -470,7 +471,6 @@ void intel_lpss_remove(struct device *dev)
470471
}
471472
EXPORT_SYMBOL_NS_GPL(intel_lpss_remove, INTEL_LPSS);
472473

473-
#ifdef CONFIG_PM
474474
static int resume_lpss_device(struct device *dev, void *data)
475475
{
476476
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)
479479
return 0;
480480
}
481481

482-
int intel_lpss_prepare(struct device *dev)
482+
static int intel_lpss_prepare(struct device *dev)
483483
{
484484
/*
485485
* Resume both child devices before entering system sleep. This
@@ -488,9 +488,8 @@ int intel_lpss_prepare(struct device *dev)
488488
device_for_each_child_reverse(dev, NULL, resume_lpss_device);
489489
return 0;
490490
}
491-
EXPORT_SYMBOL_NS_GPL(intel_lpss_prepare, INTEL_LPSS);
492491

493-
int intel_lpss_suspend(struct device *dev)
492+
static int intel_lpss_suspend(struct device *dev)
494493
{
495494
struct intel_lpss *lpss = dev_get_drvdata(dev);
496495
unsigned int i;
@@ -509,9 +508,8 @@ int intel_lpss_suspend(struct device *dev)
509508

510509
return 0;
511510
}
512-
EXPORT_SYMBOL_NS_GPL(intel_lpss_suspend, INTEL_LPSS);
513511

514-
int intel_lpss_resume(struct device *dev)
512+
static int intel_lpss_resume(struct device *dev)
515513
{
516514
struct intel_lpss *lpss = dev_get_drvdata(dev);
517515
unsigned int i;
@@ -524,8 +522,12 @@ int intel_lpss_resume(struct device *dev)
524522

525523
return 0;
526524
}
527-
EXPORT_SYMBOL_NS_GPL(intel_lpss_resume, INTEL_LPSS);
528-
#endif
525+
526+
EXPORT_NS_GPL_DEV_PM_OPS(intel_lpss_pm_ops, INTEL_LPSS) = {
527+
.prepare = pm_sleep_ptr(&intel_lpss_prepare),
528+
LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume)
529+
RUNTIME_PM_OPS(intel_lpss_suspend, intel_lpss_resume, NULL)
530+
};
529531

530532
static int __init intel_lpss_init(void)
531533
{

drivers/mfd/intel-lpss.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,6 @@ int intel_lpss_probe(struct device *dev,
3030
const struct intel_lpss_platform_info *info);
3131
void intel_lpss_remove(struct device *dev);
3232

33-
#ifdef CONFIG_PM
34-
int intel_lpss_prepare(struct device *dev);
35-
int intel_lpss_suspend(struct device *dev);
36-
int intel_lpss_resume(struct device *dev);
37-
38-
#ifdef CONFIG_PM_SLEEP
39-
#define INTEL_LPSS_SLEEP_PM_OPS \
40-
.prepare = intel_lpss_prepare, \
41-
SET_LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume)
42-
#else
43-
#define INTEL_LPSS_SLEEP_PM_OPS
44-
#endif
45-
46-
#define INTEL_LPSS_RUNTIME_PM_OPS \
47-
.runtime_suspend = intel_lpss_suspend, \
48-
.runtime_resume = intel_lpss_resume,
49-
50-
#else /* !CONFIG_PM */
51-
#define INTEL_LPSS_SLEEP_PM_OPS
52-
#define INTEL_LPSS_RUNTIME_PM_OPS
53-
#endif /* CONFIG_PM */
54-
55-
#define INTEL_LPSS_PM_OPS(name) \
56-
const struct dev_pm_ops name = { \
57-
INTEL_LPSS_SLEEP_PM_OPS \
58-
INTEL_LPSS_RUNTIME_PM_OPS \
59-
}
33+
extern const struct dev_pm_ops intel_lpss_pm_ops;
6034

6135
#endif /* __MFD_INTEL_LPSS_H */

0 commit comments

Comments
 (0)