Message ID | 20220806212331.40086-1-andriy.shevchenko@linux.intel.com |
---|---|
State | Superseded |
Headers | show |
Series | [v1,1/4] pwm: sysfs: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() | expand |
Hello, On Sun, Aug 07, 2022 at 12:23:28AM +0300, Andy Shevchenko wrote: > Using these newer macros allows the compiler to remove the unused > structure and functions when !CONFIG_PM_SLEEP + removes the need to > mark pm functions __maybe_unused. Tested on ARCH=arm allmodconfig: No change in the binary (as expected I think). When disabling PM_SLEEP the resulting change of this patch looks as follows: add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-92 (-92) Function old new delta pwm_class_pm_ops 92 - -92 Total: Before=5213, After=5121, chg -1.76% Looks like a quest to convert all SIMPLE_DEV_PM_OPS users to DEFINE_SIMPLE_DEV_PM_OPS. Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Best regards Uwe
diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index 9903c3a7eced..c21b6046067b 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -433,7 +433,7 @@ static int pwm_class_resume_npwm(struct device *parent, unsigned int npwm) return ret; } -static int __maybe_unused pwm_class_suspend(struct device *parent) +static int pwm_class_suspend(struct device *parent) { struct pwm_chip *chip = dev_get_drvdata(parent); unsigned int i; @@ -464,20 +464,20 @@ static int __maybe_unused pwm_class_suspend(struct device *parent) return ret; } -static int __maybe_unused pwm_class_resume(struct device *parent) +static int pwm_class_resume(struct device *parent) { struct pwm_chip *chip = dev_get_drvdata(parent); return pwm_class_resume_npwm(parent, chip->npwm); } -static SIMPLE_DEV_PM_OPS(pwm_class_pm_ops, pwm_class_suspend, pwm_class_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pwm_class_pm_ops, pwm_class_suspend, pwm_class_resume); static struct class pwm_class = { .name = "pwm", .owner = THIS_MODULE, .dev_groups = pwm_chip_groups, - .pm = &pwm_class_pm_ops, + .pm = pm_sleep_ptr(&pwm_class_pm_ops), }; static int pwmchip_sysfs_match(struct device *parent, const void *data)
Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pwm/sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)