Message ID | 20240301193831.3346-3-linux.amoon@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v1,1/4] usb: ehci-exynos: Use devm_clk_get_enabled() helpers | expand |
On Sat, Mar 02, 2024 at 01:08:09AM +0530, Anand Moon wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM are disabled, > without having to use #ifdef guards. If CONFIG_PM unused, > they will simply be discarded by the compiler. > > Use RUNTIME_PM_OPS runtime macro for suspend/resume function. > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > --- > drivers/usb/host/ehci-exynos.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c > index 05aa3d9c2a3b..4676f45655cd 100644 > --- a/drivers/usb/host/ehci-exynos.c > +++ b/drivers/usb/host/ehci-exynos.c > @@ -234,7 +234,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) > usb_put_hcd(hcd); > } > > -#ifdef CONFIG_PM > static int exynos_ehci_suspend(struct device *dev) > { > struct usb_hcd *hcd = dev_get_drvdata(dev); > @@ -268,14 +267,9 @@ static int exynos_ehci_resume(struct device *dev) > ehci_resume(hcd, false); > return 0; > } > -#else > -#define exynos_ehci_suspend NULL > -#define exynos_ehci_resume NULL > -#endif Doesn't this now generate warnings about functions being defined but not used when you build with CONFIG_PM disabled? Alan Stern > > static const struct dev_pm_ops exynos_ehci_pm_ops = { > - .suspend = exynos_ehci_suspend, > - .resume = exynos_ehci_resume, > + RUNTIME_PM_OPS(exynos_ehci_suspend, exynos_ehci_resume, NULL) > }; > > #ifdef CONFIG_OF > @@ -292,7 +286,7 @@ static struct platform_driver exynos_ehci_driver = { > .shutdown = usb_hcd_platform_shutdown, > .driver = { > .name = "exynos-ehci", > - .pm = &exynos_ehci_pm_ops, > + .pm = pm_ptr(&exynos_ehci_pm_ops), > .of_match_table = of_match_ptr(exynos_ehci_match), > } > }; > -- > 2.43.0 >
Hi Alan, On Sat, 2 Mar 2024 at 01:58, Alan Stern <stern@rowland.harvard.edu> wrote: > > On Sat, Mar 02, 2024 at 01:08:09AM +0530, Anand Moon wrote: > > Use the new PM macros for the suspend and resume functions to be > > automatically dropped by the compiler when CONFIG_PM are disabled, > > without having to use #ifdef guards. If CONFIG_PM unused, > > they will simply be discarded by the compiler. > > > > Use RUNTIME_PM_OPS runtime macro for suspend/resume function. > > > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > > --- > > drivers/usb/host/ehci-exynos.c | 10 ++-------- > > 1 file changed, 2 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c > > index 05aa3d9c2a3b..4676f45655cd 100644 > > --- a/drivers/usb/host/ehci-exynos.c > > +++ b/drivers/usb/host/ehci-exynos.c > > @@ -234,7 +234,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) > > usb_put_hcd(hcd); > > } > > > > -#ifdef CONFIG_PM > > static int exynos_ehci_suspend(struct device *dev) > > { > > struct usb_hcd *hcd = dev_get_drvdata(dev); > > @@ -268,14 +267,9 @@ static int exynos_ehci_resume(struct device *dev) > > ehci_resume(hcd, false); > > return 0; > > } > > -#else > > -#define exynos_ehci_suspend NULL > > -#define exynos_ehci_resume NULL > > -#endif > > Doesn't this now generate warnings about functions being defined but not > used when you build with CONFIG_PM disabled? > Yes I have tried compile the kernel with disable CONFIG_PM=n and CONFIG_PM_SLEEP=n But it's getting selected by default. Also compiled with W=1 and found no warning with these patches. To be safe I will add __maybe_unused to suspend / resume functions in the next version. diff --git a/arch/arm/configs/exynos_defconfig b/arch/arm/configs/exynos_defconfig index c98d5ff8a1ed..e96f5c3bf8c1 100644 --- a/arch/arm/configs/exynos_defconfig +++ b/arch/arm/configs/exynos_defconfig @@ -29,8 +29,10 @@ CONFIG_ARM_EXYNOS_CPUIDLE=y CONFIG_VFP=y CONFIG_NEON=y CONFIG_KERNEL_MODE_NEON=y -CONFIG_PM_DEBUG=y -CONFIG_PM_ADVANCED_DEBUG=y +# CONFIG_PM_SLEEP is not set +# CONFIG_PM is not set +# CONFIG_PM_DEBUG is not set +# CONFIG_PM_ADVANCED_DEBUG is not set CONFIG_ENERGY_MODEL=y CONFIG_KALLSYMS_ALL=y CONFIG_MODULES=y > Alan Stern Thanks -Anand
On Sat, Mar 02, 2024 at 01:08:09AM +0530, Anand Moon wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM are disabled, > without having to use #ifdef guards. If CONFIG_PM unused, > they will simply be discarded by the compiler. > > Use RUNTIME_PM_OPS runtime macro for suspend/resume function. > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > --- > drivers/usb/host/ehci-exynos.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > static const struct dev_pm_ops exynos_ehci_pm_ops = { > - .suspend = exynos_ehci_suspend, > - .resume = exynos_ehci_resume, > + RUNTIME_PM_OPS(exynos_ehci_suspend, exynos_ehci_resume, NULL) > }; This is also broken and clearly not tested. See the definition of RUNTIME_PM_OPS() which sets the runtime pm callbacks, not the suspend ones: #define RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ .runtime_suspend = suspend_fn, \ .runtime_resume = resume_fn, \ .runtime_idle = idle_fn, Johan
Hi Johan, On Mon, 4 Mar 2024 at 14:51, Johan Hovold <johan@kernel.org> wrote: > > On Sat, Mar 02, 2024 at 01:08:09AM +0530, Anand Moon wrote: > > Use the new PM macros for the suspend and resume functions to be > > automatically dropped by the compiler when CONFIG_PM are disabled, > > without having to use #ifdef guards. If CONFIG_PM unused, > > they will simply be discarded by the compiler. > > > > Use RUNTIME_PM_OPS runtime macro for suspend/resume function. > > > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > > --- > > drivers/usb/host/ehci-exynos.c | 10 ++-------- > > 1 file changed, 2 insertions(+), 8 deletions(-) > > > static const struct dev_pm_ops exynos_ehci_pm_ops = { > > - .suspend = exynos_ehci_suspend, > > - .resume = exynos_ehci_resume, > > + RUNTIME_PM_OPS(exynos_ehci_suspend, exynos_ehci_resume, NULL) > > }; > > This is also broken and clearly not tested. See the definition of > RUNTIME_PM_OPS() which sets the runtime pm callbacks, not the suspend > ones: > > #define RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ > .runtime_suspend = suspend_fn, \ > .runtime_resume = resume_fn, \ > .runtime_idle = idle_fn, > > Johan Ok, I will drop these changes. Thanks. -Anand
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 05aa3d9c2a3b..4676f45655cd 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -234,7 +234,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) usb_put_hcd(hcd); } -#ifdef CONFIG_PM static int exynos_ehci_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); @@ -268,14 +267,9 @@ static int exynos_ehci_resume(struct device *dev) ehci_resume(hcd, false); return 0; } -#else -#define exynos_ehci_suspend NULL -#define exynos_ehci_resume NULL -#endif static const struct dev_pm_ops exynos_ehci_pm_ops = { - .suspend = exynos_ehci_suspend, - .resume = exynos_ehci_resume, + RUNTIME_PM_OPS(exynos_ehci_suspend, exynos_ehci_resume, NULL) }; #ifdef CONFIG_OF @@ -292,7 +286,7 @@ static struct platform_driver exynos_ehci_driver = { .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "exynos-ehci", - .pm = &exynos_ehci_pm_ops, + .pm = pm_ptr(&exynos_ehci_pm_ops), .of_match_table = of_match_ptr(exynos_ehci_match), } };
Use the new PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM are disabled, without having to use #ifdef guards. If CONFIG_PM unused, they will simply be discarded by the compiler. Use RUNTIME_PM_OPS runtime macro for suspend/resume function. Signed-off-by: Anand Moon <linux.amoon@gmail.com> --- drivers/usb/host/ehci-exynos.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)