Skip to contentSkip to conversation

clocksource: ingenic-ost: define pm functions properly in platform_driver struct

PATCH Superseded Lukas Bulwahn 2 participants 3 messages Nov 22, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: ingenic-ost: define pm functions properly in platform_driver struct

Commit ca7b72b5a5f2 ("clocksource: Add driver for the Ingenic JZ47xx OST") adds the struct platform_driver ingenic_ost_driver, with the definition of pm functions under the non-existing config PM_SUSPEND, which means the intended pm functions were never actually included in any build.

Since commit 7a82e97a11b9 ("PM: core: introduce pm_ptr() macro"), the default pattern for platform_driver definitions is to use pm_ptr(). Assuming CONFIG_PM_SUSPEND really intended to mean CONFIG_PM (and not CONFIG_PM_SLEEP), use pm_ptr() just as most other drivers do.

Fixes ca7b72b5a5f2 ("clocksource: Add driver for the Ingenic JZ47xx OST")
---
 drivers/clocksource/ingenic-ost.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/ingenic-ost.c +1 -3
index 06d25754e606..6b64731df15c 100644
@@ -181,9 +181,7 @@ static const struct of_device_id ingenic_ost_of_match[] = {
 static struct platform_driver ingenic_ost_driver = {
 	.driver = {
 		.name = "ingenic-ost",
-#ifdef CONFIG_PM_SUSPEND
-		.pm = &ingenic_ost_pm_ops,
-#endif
+		.pm = pm_ptr(&ingenic_ost_pm_ops),
 		.of_match_table = ingenic_ost_of_match,
 	},
 };
Signature · 1 line
2.17.1
#1 lore raw

Hi Lukas,

Quoted 9 lines · Lukas Bulwahn

Commit ca7b72b5a5f2 ("clocksource: Add driver for the Ingenic JZ47xx OST") adds the struct platform_driver ingenic_ost_driver, with the definition of pm functions under the non-existing config PM_SUSPEND, which means the intended pm functions were never actually included in any build.

Since commit 7a82e97a11b9 ("PM: core: introduce pm_ptr() macro"), the default pattern for platform_driver definitions is to use pm_ptr(). Assuming CONFIG_PM_SUSPEND really intended to mean CONFIG_PM (and not CONFIG_PM_SLEEP), use pm_ptr() just as most other drivers do.

It actually was supposed to be CONFIG_PM_SLEEP, yes. You can see that because the only callbacks are .suspend_noirq and .resume_noirq. Therefore you can use pm_sleep_ptr() instead of pm_ptr().

By the way, once you use this macro then the __maybe_unused tags on the dev_pm_ops structure and its callbacks are not needed anymore, so you can remove these as well.

Quoted 1 line
Fixes ca7b72b5a5f2 ("clocksource: Add driver for the Ingenic JZ47xx OST")

That Fixes: tag won't work since the pm_ptr() macro did not exist back then (besides, you didn't Cc linux-stable).

I'd advocate to remove the Fixes: tag, since it is not really a bug fix, more like an improvement.

Cheers,
-Paul

Quoted 24 lines
---
 drivers/clocksource/ingenic-ost.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/ingenic-ost.c +1 -3
index 06d25754e606..6b64731df15c 100644
@@ -181,9 +181,7 @@ static const struct of_device_id 
 ingenic_ost_of_match[] = {
 static struct platform_driver ingenic_ost_driver = {
 	.driver = {
 		.name = "ingenic-ost",
-#ifdef CONFIG_PM_SUSPEND
-		.pm = &ingenic_ost_pm_ops,
-#endif
+		.pm = pm_ptr(&ingenic_ost_pm_ops),
 		.of_match_table = ingenic_ost_of_match,
 	},

};
--
2.17.1

#2 lore raw
Quoted 25 lines · Paul Cercueil

Hi Lukas,

Quoted 11 lines · Lukas Bulwahn

Commit ca7b72b5a5f2 ("clocksource: Add driver for the Ingenic JZ47xx OST")
adds the struct platform_driver ingenic_ost_driver, with the definition of
pm functions under the non-existing config PM_SUSPEND, which means the intended pm functions were never actually included in any build.

Since commit 7a82e97a11b9 ("PM: core: introduce pm_ptr() macro"), the default pattern for platform_driver definitions is to use pm_ptr(). Assuming CONFIG_PM_SUSPEND really intended to mean CONFIG_PM (and not CONFIG_PM_SLEEP), use pm_ptr() just as most other drivers do.

It actually was supposed to be CONFIG_PM_SLEEP, yes. You can see that because the only callbacks are .suspend_noirq and .resume_noirq. Therefore you can use pm_sleep_ptr() instead of pm_ptr().

By the way, once you use this macro then the __maybe_unused tags on the dev_pm_ops structure and its callbacks are not needed anymore, so you can remove these as well.

Quoted 9 lines
Quoted 2 lines
Fixes ca7b72b5a5f2 ("clocksource: Add driver for the Ingenic JZ47xx

OST")

That Fixes: tag won't work since the pm_ptr() macro did not exist back then (besides, you didn't Cc linux-stable).

I'd advocate to remove the Fixes: tag, since it is not really a bug fix, more like an improvement.

Thanks for the quick feedback. I will send a patch v2 incorporating that.

Lukas

Quoted 30 lines

Cheers,
-Paul

Quoted 25 lines
---
 drivers/clocksource/ingenic-ost.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/ingenic-ost.c +1 -3
index 06d25754e606..6b64731df15c 100644
@@ -181,9 +181,7 @@ static const struct of_device_id
 ingenic_ost_of_match[] = {
 static struct platform_driver ingenic_ost_driver = {
      .driver = {
              .name = "ingenic-ost",
-#ifdef CONFIG_PM_SUSPEND
-             .pm = &ingenic_ost_pm_ops,
-#endif
+             .pm = pm_ptr(&ingenic_ost_pm_ops),
              .of_match_table = ingenic_ost_of_match,
      },

};
--
2.17.1