iio: gyro: mpu3050: Cleanup exports and PM
Subsystems (2)
Jonathan Cameron
maintainercover iio: gyro: mpu3050: Cleanup exports and PM
From: Jonathan Cameron <[email protected]>
Paul Cercueil happened to chose this driver as his example for EXPORT_RUNTIME_DEV_PM_OPS() in his recent patch set to cleanup how we handle dev_pm_ops.
https://lore.kernel.org/linux-pm/[email protected]/
Whilst reviewing that I noticed that there were a bunch of exports in this driver that are only used by other files compiled into the same module. Paul found another driver to demo his new infrastructure.
This series is cleaning up that oddity by first dropping the exports and then using the new pm_ptr() and DEFINE_RUNTIME_PM_DEV_OPS() to allow the compiler to be responsible for removing the unused code for us rather than requiring manual CONFIG_PM guards.
Jonathan Cameron (2):
iio: gyro: mpu3050: Drop unused symbol exports.
iio: gyro: mpu3050: Use pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS()
drivers/iio/gyro/mpu3050-core.c | 14 ++------------ drivers/iio/gyro/mpu3050-i2c.c | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-)
Signature · 1 line
2.35.1
Jonathan Cameron
maintainerPATCH 1/2 iio: gyro: mpu3050: Drop unused symbol exports.
From: Jonathan Cameron <[email protected]>
This driver is built as a single module. There is an note in the makefile about SPI support being a reason to split the build in future. That support has never arrived so drop these symbol exports.
--- drivers/iio/gyro/mpu3050-core.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/gyro/mpu3050-core.c +0 -3
@@ -1261,7 +1261,6 @@ int mpu3050_common_probe(struct device *dev,return ret; } -EXPORT_SYMBOL (mpu3050_common_probe);int mpu3050_common_remove (struct device *dev) {
@@ -1279,7 +1278,6 @@ int mpu3050_common_remove(struct device *dev)return 0 ; } -EXPORT_SYMBOL (mpu3050_common_remove);#ifdef CONFIG_PM static int mpu3050_runtime_suspend (struct device *dev)
@@ -1299,7 +1297,6 @@ const struct dev_pm_ops mpu3050_dev_pm_ops = {SET_RUNTIME_PM_OPS (mpu3050_runtime_suspend, mpu3050_runtime_resume, NULL) }; -EXPORT_SYMBOL (mpu3050_dev_pm_ops);MODULE_AUTHOR ("Linus Walleij" );MODULE_DESCRIPTION ("MPU3050 gyroscope driver" );
Signature · 1 line
2.35.1
Re: [PATCH 1/2] iio: gyro: mpu3050: Drop unused symbol exports.
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This driver is built as a single module. There is an note in the makefile about SPI support being a reason to split the build in future. That support has never arrived so drop these symbol exports.
Signed-off-by Jonathan Cameron <[email protected]>Cc Linus Walleij <[email protected]>
Yours,
Linus Walleij
Jonathan Cameron
maintainerPATCH 2/2 iio: gyro: mpu3050: Use pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Using this approach as opposed to CONFIG_PM guards allows the compiler to remove the unused code instead of doing it manually.
--- drivers/iio/gyro/mpu3050-core.c | 11 ++--------- drivers/iio/gyro/mpu3050-i2c.c | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/iio/gyro/mpu3050-core.c +2 -9
@@ -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" );
drivers/iio/gyro/mpu3050-i2c.c +1 -1
@@ -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);
Signature · 1 line
2.35.1
Re: [PATCH 2/2] iio: gyro: mpu3050: Use pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS()
Quoted 7 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Using this approach as opposed to
CONFIG_PMguards allows the compiler to remove the unused code instead of doing it manually.Signed-off-by Jonathan Cameron <[email protected]>Cc Linus Walleij <[email protected]>
Very nice!
Yours,
Linus Walleij
Jonathan Cameron
maintainerQuoted 8 lines · On Sun, 20 Feb 2022 17:51:47 +0000 Jonathan Cameron <[email protected]> wrote:
From: Jonathan Cameron <[email protected]>
Paul Cercueil happened to chose this driver as his example for
EXPORT_RUNTIME_DEV_PM_OPS()in his recent patch set to cleanup how we handledev_pm_ops.
Quoted 9 lines
Whilst reviewing that I noticed that there were a bunch of exports in this driver that are only used by other files compiled into the same module. Paul found another driver to demo his new infrastructure.
This series is cleaning up that oddity by first dropping the exports and then using the new
pm_ptr()andDEFINE_RUNTIME_PM_DEV_OPS()to allow the compiler to be responsible for removing the unused code for us rather than requiring manualCONFIG_PMguards.
Oops. Lost my own series down the back of the sofa. No idea why I didn't apply these when Linus reviewed them back in March.
Anyhow, now applied to the togreg branch of iio.git (with some fuzz) and pushed out as testing to see if 0-day is happy with them.
Thanks,
Jonathan
Quoted 8 lines
Jonathan Cameron (2):
iio: gyro: mpu3050: Drop unused symbol exports.
iio: gyro: mpu3050: Usepm_ptr()andDEFINE_RUNTIME_DEV_PM_OPS()drivers/iio/gyro/mpu3050-core.c | 14 ++------------ drivers/iio/gyro/mpu3050-i2c.c | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-)