Skip to contentSkip to conversation

backlight: pwm_bl: Use SIMPLE_DEV_PM_OPS()

PATCH Superseded Alexander Shiyan 2 participants 2 messages Dec 16, 2018 – Dec 17, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backlight: pwm_bl: Use SIMPLE_DEV_PM_OPS()

Use the SIMPLE_DEV_PM_OPS() macro to declare the driver's pm_ops. As a side effect, removing #ifdef CONFIG_PM_SLEEP will improve compilation coverage.

---
 drivers/video/backlight/pwm_bl.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/video/backlight/pwm_bl.c +4 -13
index f9ef067..33503ce 100644
@@ -667,8 +667,7 @@ static void pwm_backlight_shutdown(struct platform_device *pdev)
 	pwm_backlight_power_off(pb);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int pwm_backlight_suspend(struct device *dev)
+static int __maybe_unused pwm_bl_suspend(struct device *dev)
 {
 	struct backlight_device *bl = dev_get_drvdata(dev);
 	struct pwm_bl_data *pb = bl_get_data(bl);
@@ -684,7 +683,7 @@ static int pwm_backlight_suspend(struct device *dev)
 	return 0;
 }
 
-static int pwm_backlight_resume(struct device *dev)
+static int __maybe_unused pwm_bl_resume(struct device *dev)
 {
 	struct backlight_device *bl = dev_get_drvdata(dev);
 
@@ -692,21 +691,13 @@ static int pwm_backlight_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops pwm_backlight_pm_ops = {
-#ifdef CONFIG_PM_SLEEP
-	.suspend = pwm_backlight_suspend,
-	.resume = pwm_backlight_resume,
-	.poweroff = pwm_backlight_suspend,
-	.restore = pwm_backlight_resume,
-#endif
-};
+static SIMPLE_DEV_PM_OPS(pwm_bl_pm_ops, pwm_bl_suspend, pwm_bl_resume);
 
 static struct platform_driver pwm_backlight_driver = {
 	.driver		= {
 		.name		= "pwm-backlight",
-		.pm		= &pwm_backlight_pm_ops,
+		.pm		= &pwm_bl_pm_ops,
 		.of_match_table	= of_match_ptr(pwm_backlight_of_match),
 	},
 	.probe		= pwm_backlight_probe,
Signature · 1 line
2.10.2
#1 lore raw
Quoted 14 lines · Alexander Shiyan

Use the SIMPLE_DEV_PM_OPS() macro to declare the driver's pm_ops. As a side effect, removing #ifdef CONFIG_PM_SLEEP will improve compilation coverage.

---
 drivers/video/backlight/pwm_bl.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/video/backlight/pwm_bl.c +0 -0
index f9ef067..33503ce 100644

drivers/video/backlight/pwm_bl.c static void pwm_backlight_shutdown(struct platform_device *pdev) · line 670

Quoted 6 lines
drivers/video/backlight/pwm_bl.c +1 -2
@@ -667,8 +667,7 @@ static void pwm_backlight_shutdown(struct platform_device *pdev)
 	pwm_backlight_power_off(pb);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int pwm_backlight_suspend(struct device *dev)
+static int __maybe_unused pwm_bl_suspend(struct device *dev)

Why rename the symbol. It no longer matches the coding style of the file.

drivers/video/backlight/pwm_bl.c static int pwm_backlight_suspend(struct device *dev) · line 686

Quoted 9 lines
drivers/video/backlight/pwm_bl.c +1 -1
 {
 	struct backlight_device *bl = dev_get_drvdata(dev);
 	struct pwm_bl_data *pb = bl_get_data(bl);
@@ -684,7 +683,7 @@ static int pwm_backlight_suspend(struct device *dev)
 	return 0;
 }
 
-static int pwm_backlight_resume(struct device *dev)
+static int __maybe_unused pwm_bl_resume(struct device *dev)

Same here.

Quoted 8 lines
drivers/video/backlight/pwm_bl.c +0 -1
 {
 	struct backlight_device *bl = dev_get_drvdata(dev);
 
@@ -692,21 +691,13 @@ static int pwm_backlight_resume(struct device *dev)
 
 	return 0;
 }
-#endif

drivers/video/backlight/pwm_bl.c static int pwm_backlight_resume(struct device *dev) · line 695

Quoted 10 lines
drivers/video/backlight/pwm_bl.c +1 -8
 
-static const struct dev_pm_ops pwm_backlight_pm_ops = {
-#ifdef CONFIG_PM_SLEEP
-	.suspend = pwm_backlight_suspend,
-	.resume = pwm_backlight_resume,
-	.poweroff = pwm_backlight_suspend,
-	.restore = pwm_backlight_resume,
-#endif
-};
+static SIMPLE_DEV_PM_OPS(pwm_bl_pm_ops, pwm_bl_suspend, pwm_bl_resume);

And same here...

Daniel.

Quoted 12 lines
drivers/video/backlight/pwm_bl.c +1 -1
 static struct platform_driver pwm_backlight_driver = {
 	.driver		= {
 		.name		= "pwm-backlight",
-		.pm		= &pwm_backlight_pm_ops,
+		.pm		= &pwm_bl_pm_ops,
 		.of_match_table	= of_match_ptr(pwm_backlight_of_match),
 	},
 	.probe		= pwm_backlight_probe,
Signature · 1 line
2.10.2