Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>, Jean Delvare <jdelvare@suse.com>
Cc: linux-hwmon@vger.kernel.org
Subject: [PATCH] hwmon: jc42: Simplify pm ops handling
Date: Mon, 13 Nov 2023 20:20:49 +0100	[thread overview]
Message-ID: <23f24d6d-ae79-4014-b4df-dc19ddb88e3f@gmail.com> (raw)

Use pm_sleep_ptr/DEFINE_SIMPLE_DEV_PM_OPS to simplify the code.

Note: Apparently conditional compiling based on CONFIG_PM
wasn't optimal, it should have been CONFIG_PM_SLEEP.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/hwmon/jc42.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
index f958e830b..5cd0b8cc6 100644
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -570,8 +570,6 @@ static void jc42_remove(struct i2c_client *client)
 	}
 }
 
-#ifdef CONFIG_PM
-
 static int jc42_suspend(struct device *dev)
 {
 	struct jc42_data *data = dev_get_drvdata(dev);
@@ -598,15 +596,7 @@ static int jc42_resume(struct device *dev)
 	return regcache_sync(data->regmap);
 }
 
-static const struct dev_pm_ops jc42_dev_pm_ops = {
-	.suspend = jc42_suspend,
-	.resume = jc42_resume,
-};
-
-#define JC42_DEV_PM_OPS (&jc42_dev_pm_ops)
-#else
-#define JC42_DEV_PM_OPS NULL
-#endif /* CONFIG_PM */
+static DEFINE_SIMPLE_DEV_PM_OPS(jc42_pm_ops, jc42_suspend, jc42_resume);
 
 static const struct i2c_device_id jc42_id[] = {
 	{ "jc42", 0 },
@@ -626,7 +616,7 @@ static struct i2c_driver jc42_driver = {
 	.class		= I2C_CLASS_SPD | I2C_CLASS_HWMON,
 	.driver = {
 		.name	= "jc42",
-		.pm = JC42_DEV_PM_OPS,
+		.pm = pm_sleep_ptr(&jc42_pm_ops),
 		.of_match_table = of_match_ptr(jc42_of_ids),
 	},
 	.probe		= jc42_probe,
-- 
2.42.1


             reply	other threads:[~2023-11-13 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 19:20 Heiner Kallweit [this message]
2023-11-14 13:53 ` [PATCH] hwmon: jc42: Simplify pm ops handling Guenter Roeck
2023-11-14 14:16   ` Heiner Kallweit

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=23f24d6d-ae79-4014-b4df-dc19ddb88e3f@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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