Message ID | 20230705204314.89800-15-paul@crapouillou.net |
---|---|
State | Superseded |
Headers | show |
Series | i2c: Use new PM macros | expand |
On Wed, 5 Jul 2023 22:43:05 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards. > > This has the advantage of always compiling these functions in, > independently of any Kconfig option. Thanks to that, bugs and other > regressions are subsequently easier to catch. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > Might be worth rewrapping the runtime pm line. Otherwise LGTM Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > Cc: Linus Walleij <linus.walleij@linaro.org> > Cc: linux-arm-kernel@lists.infradead.org > --- > drivers/i2c/busses/i2c-nomadik.c | 14 +++++--------- > 1 file changed, 5 insertions(+), 9 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c > index 1e5fd23ef45c..4a4b5bc257ae 100644 > --- a/drivers/i2c/busses/i2c-nomadik.c > +++ b/drivers/i2c/busses/i2c-nomadik.c > @@ -873,7 +873,6 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) > return IRQ_HANDLED; > } > > -#ifdef CONFIG_PM_SLEEP > static int nmk_i2c_suspend_late(struct device *dev) > { > int ret; > @@ -890,9 +889,7 @@ static int nmk_i2c_resume_early(struct device *dev) > { > return pm_runtime_force_resume(dev); > } > -#endif > > -#ifdef CONFIG_PM > static int nmk_i2c_runtime_suspend(struct device *dev) > { > struct amba_device *adev = to_amba_device(dev); > @@ -925,13 +922,12 @@ static int nmk_i2c_runtime_resume(struct device *dev) > > return ret; > } > -#endif > > static const struct dev_pm_ops nmk_i2c_pm = { > - SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) > - SET_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, > - nmk_i2c_runtime_resume, > - NULL) > + LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) > + RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, > + nmk_i2c_runtime_resume, > + NULL) rewrap? > }; > > static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) > @@ -1080,7 +1076,7 @@ static struct amba_driver nmk_i2c_driver = { > .drv = { > .owner = THIS_MODULE, > .name = DRIVER_NAME, > - .pm = &nmk_i2c_pm, > + .pm = pm_ptr(&nmk_i2c_pm), > }, > .id_table = nmk_i2c_ids, > .probe = nmk_i2c_probe,
On Wed, Jul 5, 2023 at 10:43 PM Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards. > > This has the advantage of always compiling these functions in, > independently of any Kconfig option. Thanks to that, bugs and other > regressions are subsequently easier to catch. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> Looks correct! Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 1e5fd23ef45c..4a4b5bc257ae 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -873,7 +873,6 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) return IRQ_HANDLED; } -#ifdef CONFIG_PM_SLEEP static int nmk_i2c_suspend_late(struct device *dev) { int ret; @@ -890,9 +889,7 @@ static int nmk_i2c_resume_early(struct device *dev) { return pm_runtime_force_resume(dev); } -#endif -#ifdef CONFIG_PM static int nmk_i2c_runtime_suspend(struct device *dev) { struct amba_device *adev = to_amba_device(dev); @@ -925,13 +922,12 @@ static int nmk_i2c_runtime_resume(struct device *dev) return ret; } -#endif static const struct dev_pm_ops nmk_i2c_pm = { - SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) - SET_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, - nmk_i2c_runtime_resume, - NULL) + LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) + RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, + nmk_i2c_runtime_resume, + NULL) }; static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) @@ -1080,7 +1076,7 @@ static struct amba_driver nmk_i2c_driver = { .drv = { .owner = THIS_MODULE, .name = DRIVER_NAME, - .pm = &nmk_i2c_pm, + .pm = pm_ptr(&nmk_i2c_pm), }, .id_table = nmk_i2c_ids, .probe = nmk_i2c_probe,
Use the new PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards. This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch. Signed-off-by: Paul Cercueil <paul@crapouillou.net> --- Cc: Linus Walleij <linus.walleij@linaro.org> Cc: linux-arm-kernel@lists.infradead.org --- drivers/i2c/busses/i2c-nomadik.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)