i2c: amd-mp2-pci: Simplify PM code using DEFINE_RUNTIME_DEV_PM_OPS
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest1 patch 0 repliesNew
- v11 patch 0 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | i2c: amd-mp2-pci: Simplify PM code using DEFINE_RUNTIME_DEV_PM_OPS | +0 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/1] i2c: amd-mp2-pci: Simplify PM code using DEFINE_RUNTIME_DEV_PM_OPS
Simplify the power management code by:
1. Removing the redundant #ifdef CONFIG_PM guards as the DEFINE_RUNTIME_DEV_PM_OPS() macro already handles PM_SLEEP dependencies automatically.
2. Replacing UNIVERSAL_DEV_PM_OPS with DEFINE_RUNTIME_DEV_PM_OPS() which is more appropriate for runtime power management.
3. Using pm_sleep_ptr() for the driver's pm_ops to allow the compiler to eliminate unused code when CONFIG_PM_SLEEP is disabled.
This change reduces preprocessor conditional complexity and ensures better code elimination for non-PM configurations.
Signed-off-by Artem Shimko <[email protected]>
--- drivers/i2c/busses/i2c-amd-mp2-pci.c | 8 ++------ drivers/i2c/busses/i2c-amd-mp2-plat.c | 4 ---- drivers/i2c/busses/i2c-amd-mp2.h | 2 -- 3 files changed, 2 insertions(+), 12 deletions(-)
drivers/i2c/busses/i2c-amd-mp2-pci.c +2 -6
@@ -379,7 +379,6 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev)amd_mp2_clear_reg (privdata); } -#ifdef CONFIG_PM static int amd_mp2_pci_suspend (struct device *dev) {struct pci_dev *pci_dev =to_pci_dev (dev);
@@ -431,9 +430,8 @@ static int amd_mp2_pci_resume(struct device *dev)return ret; } -static UNIVERSAL_DEV_PM_OPS(amd_mp2_pci_pm_ops, amd_mp2_pci_suspend, +static DEFINE_RUNTIME_DEV_PM_OPS(amd_mp2_pci_pm_ops, amd_mp2_pci_suspend, amd_mp2_pci_resume, NULL); -#endif /* CONFIG_PM */ static const struct pci_device_id amd_mp2_pci_tbl[] = { {PCI_VDEVICE (AMD ,PCI_DEVICE_ID_AMD_MP2 )},
@@ -446,11 +444,9 @@ static struct pci_driver amd_mp2_pci_driver = { .id_table = amd_mp2_pci_tbl, .probe = amd_mp2_pci_probe, .remove = amd_mp2_pci_remove, -#ifdef CONFIG_PM .driver = { - .pm = &amd_mp2_pci_pm_ops, + .pm = pm_sleep_ptr(&amd_mp2_pci_pm_ops), }, -#endif };module_pci_driver (amd_mp2_pci_driver);
drivers/i2c/busses/i2c-amd-mp2-plat.c +0 -4
@@ -183,7 +183,6 @@ static const struct i2c_algorithm i2c_amd_algorithm = { .functionality = i2c_amd_func, }; -#ifdef CONFIG_PM static int i2c_amd_suspend (struct amd_i2c_common *i2c_common) {struct amd_i2c_dev *i2c_dev =amd_i2c_dev_common (i2c_common);
@@ -198,7 +197,6 @@ static int i2c_amd_resume(struct amd_i2c_common *i2c_common)return i2c_amd_enable_set (i2c_dev, true); } -#endif static const u32 supported_speeds[] = {I2C_MAX_HIGH_SPEED_MODE_FREQ ,
@@ -276,10 +274,8 @@ static int i2c_amd_probe(struct platform_device *pdev)platform_set_drvdata (pdev, i2c_dev); i2c_dev->common.cmd_completion = &i2c_amd_cmd_completion; -#ifdef CONFIG_PM i2c_dev->common.suspend = &i2c_amd_suspend; i2c_dev->common.resume = &i2c_amd_resume; -#endif /* Register the adapter */ amd_mp2_pm_runtime_get (mp2_dev);
drivers/i2c/busses/i2c-amd-mp2.h +0 -2
@@ -160,10 +160,8 @@ struct amd_i2c_common {enum speed_enum i2c_speed;u8 *dma_buf;dma_addr_t dma_addr; -#ifdef CONFIG_PM int (*suspend)(struct amd_i2c_common *i2c_common);int (*resume)(struct amd_i2c_common *i2c_common); -#endif /* CONFIG_PM */ };/**
Signature · 1 line
2.43.0