From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Paul Cercueil <paul@crapouillou.net>,
Linus Walleij <linus.walleij@linaro.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH 2/2] iio: gyro: mpu3050: Use pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS()
Date: Sun, 20 Feb 2022 17:51:49 +0000 [thread overview]
Message-ID: <20220220175149.503495-3-jic23@kernel.org> (raw)
In-Reply-To: <20220220175149.503495-1-jic23@kernel.org>
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Using this approach as opposed to CONFIG_PM guards allows the compiler to
remove the unused code instead of doing it manually.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
drivers/iio/gyro/mpu3050-core.c | 11 ++---------
drivers/iio/gyro/mpu3050-i2c.c | 2 +-
2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index 8486261beb90..b3ecb5571057 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -1279,7 +1279,6 @@ int mpu3050_common_remove(struct device *dev)
return 0;
}
-#ifdef CONFIG_PM
static int mpu3050_runtime_suspend(struct device *dev)
{
return mpu3050_power_down(iio_priv(dev_get_drvdata(dev)));
@@ -1289,15 +1288,9 @@ static int mpu3050_runtime_resume(struct device *dev)
{
return mpu3050_power_up(iio_priv(dev_get_drvdata(dev)));
}
-#endif /* CONFIG_PM */
-
-const struct dev_pm_ops mpu3050_dev_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
- pm_runtime_force_resume)
- SET_RUNTIME_PM_OPS(mpu3050_runtime_suspend,
- mpu3050_runtime_resume, NULL)
-};
+DEFINE_RUNTIME_DEV_PM_OPS(mpu3050_dev_pm_ops, mpu3050_runtime_suspend,
+ mpu3050_runtime_resume, NULL);
MODULE_AUTHOR("Linus Walleij");
MODULE_DESCRIPTION("MPU3050 gyroscope driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
index ef5bcbc4b45b..820133cad601 100644
--- a/drivers/iio/gyro/mpu3050-i2c.c
+++ b/drivers/iio/gyro/mpu3050-i2c.c
@@ -114,7 +114,7 @@ static struct i2c_driver mpu3050_i2c_driver = {
.driver = {
.of_match_table = mpu3050_i2c_of_match,
.name = "mpu3050-i2c",
- .pm = &mpu3050_dev_pm_ops,
+ .pm = pm_ptr(&mpu3050_dev_pm_ops),
},
};
module_i2c_driver(mpu3050_i2c_driver);
--
2.35.1
next prev parent reply other threads:[~2022-02-20 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-20 17:51 [PATCH 0/2] iio: gyro: mpu3050: Cleanup exports and PM Jonathan Cameron
2022-02-20 17:51 ` [PATCH 1/2] iio: gyro: mpu3050: Drop unused symbol exports Jonathan Cameron
2022-03-15 0:32 ` Linus Walleij
2022-02-20 17:51 ` Jonathan Cameron [this message]
2022-03-15 0:33 ` [PATCH 2/2] iio: gyro: mpu3050: Use pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS() Linus Walleij
2022-06-04 15:56 ` [PATCH 0/2] iio: gyro: mpu3050: Cleanup exports and PM Jonathan Cameron
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=20220220175149.503495-3-jic23@kernel.org \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=paul@crapouillou.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