Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Andy Shevchenko and committed by
Lee Jones
fd58bb8c 24ee97a9

+15 -41
+2 -3
drivers/mfd/intel-lpss-acpi.c
··· 13 13 #include <linux/ioport.h> 14 14 #include <linux/mod_devicetable.h> 15 15 #include <linux/module.h> 16 + #include <linux/pm.h> 16 17 #include <linux/pm_runtime.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/property.h> ··· 206 205 pm_runtime_disable(&pdev->dev); 207 206 } 208 207 209 - static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops); 210 - 211 208 static struct platform_driver intel_lpss_acpi_driver = { 212 209 .probe = intel_lpss_acpi_probe, 213 210 .remove_new = intel_lpss_acpi_remove, 214 211 .driver = { 215 212 .name = "intel-lpss", 216 213 .acpi_match_table = intel_lpss_acpi_ids, 217 - .pm = &intel_lpss_acpi_pm_ops, 214 + .pm = pm_ptr(&intel_lpss_pm_ops), 218 215 }, 219 216 }; 220 217
+2 -3
drivers/mfd/intel-lpss-pci.c
··· 13 13 #include <linux/mod_devicetable.h> 14 14 #include <linux/module.h> 15 15 #include <linux/pci.h> 16 + #include <linux/pm.h> 16 17 #include <linux/pm_runtime.h> 17 18 #include <linux/property.h> 18 19 ··· 81 80 82 81 intel_lpss_remove(&pdev->dev); 83 82 } 84 - 85 - static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops); 86 83 87 84 static const struct property_entry spt_spi_properties[] = { 88 85 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_SPT_SSP), ··· 592 593 .probe = intel_lpss_pci_probe, 593 594 .remove = intel_lpss_pci_remove, 594 595 .driver = { 595 - .pm = &intel_lpss_pci_pm_ops, 596 + .pm = pm_ptr(&intel_lpss_pm_ops), 596 597 }, 597 598 }; 598 599
+10 -8
drivers/mfd/intel-lpss.c
··· 24 24 #include <linux/ioport.h> 25 25 #include <linux/mfd/core.h> 26 26 #include <linux/module.h> 27 + #include <linux/pm.h> 27 28 #include <linux/pm_qos.h> 28 29 #include <linux/pm_runtime.h> 29 30 #include <linux/sprintf.h> ··· 471 470 } 472 471 EXPORT_SYMBOL_NS_GPL(intel_lpss_remove, INTEL_LPSS); 473 472 474 - #ifdef CONFIG_PM 475 473 static int resume_lpss_device(struct device *dev, void *data) 476 474 { 477 475 if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND)) ··· 479 479 return 0; 480 480 } 481 481 482 - int intel_lpss_prepare(struct device *dev) 482 + static int intel_lpss_prepare(struct device *dev) 483 483 { 484 484 /* 485 485 * Resume both child devices before entering system sleep. This ··· 488 488 device_for_each_child_reverse(dev, NULL, resume_lpss_device); 489 489 return 0; 490 490 } 491 - EXPORT_SYMBOL_NS_GPL(intel_lpss_prepare, INTEL_LPSS); 492 491 493 - int intel_lpss_suspend(struct device *dev) 492 + static int intel_lpss_suspend(struct device *dev) 494 493 { 495 494 struct intel_lpss *lpss = dev_get_drvdata(dev); 496 495 unsigned int i; ··· 508 509 509 510 return 0; 510 511 } 511 - EXPORT_SYMBOL_NS_GPL(intel_lpss_suspend, INTEL_LPSS); 512 512 513 - int intel_lpss_resume(struct device *dev) 513 + static int intel_lpss_resume(struct device *dev) 514 514 { 515 515 struct intel_lpss *lpss = dev_get_drvdata(dev); 516 516 unsigned int i; ··· 522 524 523 525 return 0; 524 526 } 525 - EXPORT_SYMBOL_NS_GPL(intel_lpss_resume, INTEL_LPSS); 526 - #endif 527 + 528 + EXPORT_NS_GPL_DEV_PM_OPS(intel_lpss_pm_ops, INTEL_LPSS) = { 529 + .prepare = pm_sleep_ptr(&intel_lpss_prepare), 530 + LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume) 531 + RUNTIME_PM_OPS(intel_lpss_suspend, intel_lpss_resume, NULL) 532 + }; 527 533 528 534 static int __init intel_lpss_init(void) 529 535 {
+1 -27
drivers/mfd/intel-lpss.h
··· 30 30 const struct intel_lpss_platform_info *info); 31 31 void intel_lpss_remove(struct device *dev); 32 32 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; 60 34 61 35 #endif /* __MFD_INTEL_LPSS_H */