mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Artem Shimko <artyom.shimko@gmail.com>
Cc: Artem Shimko <artyom.shimko@gmail.com>,
	Elie Morisse <syniurge@gmail.com>,
	Shyam Sundar S K <shyam-sundar.s-k@amd.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] i2c: amd-mp2-pci: Simplify PM code using DEFINE_RUNTIME_DEV_PM_OPS
Date: Sat,  6 Sep 2025 03:12:08 +0300	[thread overview]
Message-ID: <20250906001217.3792723-2-artyom.shimko@gmail.com> (raw)
In-Reply-To: <20250906001217.3792723-1-artyom.shimko@gmail.com>

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@gmail.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


  reply	other threads:[~2025-09-06  0:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-06  0:12 [PATCH 0/1] " Artem Shimko
2025-09-06  0:12 ` Artem Shimko [this message]
2025-09-06 21:26   ` [PATCH 1/1] " kernel test robot
     [not found]     ` <20250908115942.752356-1-artyom.shimko@gmail.com>
2025-09-08 11:59       ` [PATCH v2 0/1] " Artem Shimko
2025-09-08 12:11     ` [PATCH v2 1/1] " Artem Shimko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250906001217.3792723-2-artyom.shimko@gmail.com \
    --to=artyom.shimko@gmail.com \
    --cc=andi.shyti@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shyam-sundar.s-k@amd.com \
    --cc=syniurge@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®