[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250906001217.3792723-2-artyom.shimko@gmail.com>
Date: Sat, 6 Sep 2025 03:12:08 +0300
From: Artem Shimko <artyom.shimko@...il.com>
To:
Cc: Artem Shimko <artyom.shimko@...il.com>,
Elie Morisse <syniurge@...il.com>,
Shyam Sundar S K <shyam-sundar.s-k@....com>,
Andi Shyti <andi.shyti@...nel.org>,
linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/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 <artyom.shimko@...il.com>
---
drivers/i2c/busses/i2c-amd-mp2-pci.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
index ef7370d3dbea..8f148c4d641f 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
@@ -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);
--
2.43.0
Powered by blists - more mailing lists