mbox series

[00/32] Input: Joystick keyboard switch to DEFINE_SIMPLE_DEV_PM_OPS()

Message ID 20221204180841.2211588-1-jic23@kernel.org
Headers show
Series Input: Joystick keyboard switch to DEFINE_SIMPLE_DEV_PM_OPS() | expand

Message

Jonathan Cameron Dec. 4, 2022, 6:08 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As part of recent changes to the macros in linux/pm.h, the
SIMPLE_DEV_PM_OPS() macro is deprecated in favor of the comination
of DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
More details in the relevant commit message.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1a3c7bb088266fa2db017be299f91f1c1894c857

The main advantage of the new versions is that they allow the compiler
to 'see' the callbacks registered, thus avoiding the need to either
protect them with ifdef guards or to mark them __maybe_unused.
The compiler then removes the structure and the callbacks as dead code
in event of !CONFIG_PM_SLEEP.

Ultimately to clean up the old macros the change needs to be done to
all instances of the SIMPLE_DEV_PM_OPS() in the kernel. There are similar
changes to be done for runtime PM macros and more complex PM handling.
This set is just meant to switch over some of the low hanging fruit in
a bite sized chunk.

Also included at the end of this series are:
* a warning fix for pxspad
* allowing various drivers to be build with CONFIG_COMPILE_TEST.

There was one case that really is architecture specific for which I
did only a partial build test.  I pushed these out in a branch that
0-day build and it didn't see any problems.

Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Tomohiro Yoshidomi <sylph23k@gmail.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Stephen Boyd <swboyd@chromium.org>
Cc: Yassine Oudjana <y.oudjana@protonmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Michal Vokáč <michal.vokac@ysoft.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Marek Vasut <marek.vasut@gmail.com>

Jonathan Cameron (32):
  Input: pxspad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: adp5589-keys - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: cros-ec-keyb - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: cypress-sf - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: ep39xx-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: gpio-keys - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: ipaq-micro-keys - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: mpr121-touchkey - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: mtk-pmic-keys - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: qt1050 - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: spear-keyboard - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: tm2-touchkey - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: lm8323 - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: lpc32xx-keys - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: matrix-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: max7359-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: mcs-touchkey - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: nomadik-ske-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: pmic8xxx-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: pxa27x_keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: qt1070 - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: sh-keysc - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: st-keyscan - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: tc3589x - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: tca6416-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: tegra-kbc - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
    pm_sleep_ptr()
  Input: tegra-kbc - allow build with COMPILE_TEST
  Input: spear-keyboard - improve build coverage using COMPILE_TEST
  Input: pxa27xx-keypad - allow build with COMPILE_TEST
  Input: nomadik-ske-keypad - allow building with COMPILE_TEST
  Input: lpc32xx - allow building with COMPILE_TEST
  Input: pxspad: Fix unused data warning when force feedback not
    enabled.

 drivers/input/joystick/psxpad-spi.c         |  9 ++++++---
 drivers/input/keyboard/Kconfig              | 10 +++++-----
 drivers/input/keyboard/adp5589-keys.c       |  8 ++++----
 drivers/input/keyboard/cros_ec_keyb.c       |  6 +++---
 drivers/input/keyboard/cypress-sf.c         | 10 +++++-----
 drivers/input/keyboard/ep93xx_keypad.c      | 10 +++++-----
 drivers/input/keyboard/gpio_keys.c          |  8 ++++----
 drivers/input/keyboard/ipaq-micro-keys.c    | 10 +++++-----
 drivers/input/keyboard/lm8323.c             |  6 ++----
 drivers/input/keyboard/lpc32xx-keys.c       |  8 +++-----
 drivers/input/keyboard/matrix_keypad.c      |  8 +++-----
 drivers/input/keyboard/max7359_keypad.c     |  6 ++----
 drivers/input/keyboard/mcs_touchkey.c       |  8 +++-----
 drivers/input/keyboard/mpr121_touchkey.c    |  8 ++++----
 drivers/input/keyboard/mtk-pmic-keys.c      | 10 +++++-----
 drivers/input/keyboard/nomadik-ske-keypad.c |  8 +++-----
 drivers/input/keyboard/pmic8xxx-keypad.c    |  8 +++-----
 drivers/input/keyboard/pxa27x_keypad.c      |  8 +++-----
 drivers/input/keyboard/qt1050.c             |  8 ++++----
 drivers/input/keyboard/qt1070.c             |  6 ++----
 drivers/input/keyboard/sh_keysc.c           |  8 +++-----
 drivers/input/keyboard/spear-keyboard.c     |  9 +++++----
 drivers/input/keyboard/st-keyscan.c         |  7 +++----
 drivers/input/keyboard/tc3589x-keypad.c     |  8 +++-----
 drivers/input/keyboard/tca6416-keypad.c     |  8 +++-----
 drivers/input/keyboard/tegra-kbc.c          |  7 +++----
 drivers/input/keyboard/tm2-touchkey.c       | 10 +++++-----
 27 files changed, 99 insertions(+), 121 deletions(-)

Comments

Mattijs Korpershoek Dec. 5, 2022, 1:23 p.m. UTC | #1
On Sun, Dec 04, 2022 at 18:08, Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
> against unused function warnings.  The new combination of pm_sleep_ptr()
> and DEFINE_SIMPLE_DEV_PM_OPS() allows the compiler to see the functions,
> thus suppressing the warning, but still allowing the unused code to be
> removed. Thus also drop the __maybe_unused markings.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>  drivers/input/keyboard/mtk-pmic-keys.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 9b34da0ec260..3d4ffa25e3df 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -231,7 +231,7 @@ static int mtk_pmic_key_setup(struct mtk_pmic_keys *keys,
>  	return 0;
>  }
>  
> -static int __maybe_unused mtk_pmic_keys_suspend(struct device *dev)
> +static int mtk_pmic_keys_suspend(struct device *dev)
>  {
>  	struct mtk_pmic_keys *keys = dev_get_drvdata(dev);
>  	int index;
> @@ -247,7 +247,7 @@ static int __maybe_unused mtk_pmic_keys_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused mtk_pmic_keys_resume(struct device *dev)
> +static int mtk_pmic_keys_resume(struct device *dev)
>  {
>  	struct mtk_pmic_keys *keys = dev_get_drvdata(dev);
>  	int index;
> @@ -263,8 +263,8 @@ static int __maybe_unused mtk_pmic_keys_resume(struct device *dev)
>  	return 0;
>  }
>  
> -static SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend,
> -			mtk_pmic_keys_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend,
> +				mtk_pmic_keys_resume);
>  
>  static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
>  	{
> @@ -387,7 +387,7 @@ static struct platform_driver pmic_keys_pdrv = {
>  	.driver = {
>  		   .name = "mtk-pmic-keys",
>  		   .of_match_table = of_mtk_pmic_keys_match_tbl,
> -		   .pm = &mtk_pmic_keys_pm_ops,
> +		   .pm = pm_sleep_ptr(&mtk_pmic_keys_pm_ops),
>  	},
>  };
>  
> -- 
> 2.38.1
Linus Walleij Dec. 6, 2022, 11:43 p.m. UTC | #2
On Sun, Dec 4, 2022 at 6:56 PM Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
> against unused function warnings.  The new combination of pm_sleep_ptr()
> and DEFINE_SIMPLE_DEV_PM_OPS() allows the compiler to see the functions,
> thus suppressing the warning, but still allowing the unused code to be
> removed. Thus also drop the ifdef guards.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Stephen Boyd Dec. 7, 2022, 12:41 a.m. UTC | #3
Quoting Jonathan Cameron (2022-12-04 10:08:12)
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
> against unused function warnings.  The new combination of pm_sleep_ptr()
> and DEFINE_SIMPLE_DEV_PM_OPS() allows the compiler to see the functions,
> thus suppressing the warning, but still allowing the unused code to be
> removed. Thus also drop the __maybe_unused markings.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Stephen Boyd <swboyd@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Dmitry Torokhov Dec. 7, 2022, 9:47 p.m. UTC | #4
On Sun, Dec 04, 2022 at 06:08:09PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> As part of recent changes to the macros in linux/pm.h, the
> SIMPLE_DEV_PM_OPS() macro is deprecated in favor of the comination
> of DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
> More details in the relevant commit message.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1a3c7bb088266fa2db017be299f91f1c1894c857
> 
> The main advantage of the new versions is that they allow the compiler
> to 'see' the callbacks registered, thus avoiding the need to either
> protect them with ifdef guards or to mark them __maybe_unused.
> The compiler then removes the structure and the callbacks as dead code
> in event of !CONFIG_PM_SLEEP.
> 
> Ultimately to clean up the old macros the change needs to be done to
> all instances of the SIMPLE_DEV_PM_OPS() in the kernel. There are similar
> changes to be done for runtime PM macros and more complex PM handling.
> This set is just meant to switch over some of the low hanging fruit in
> a bite sized chunk.
> 
> Also included at the end of this series are:
> * a warning fix for pxspad
> * allowing various drivers to be build with CONFIG_COMPILE_TEST.
> 
> There was one case that really is architecture specific for which I
> did only a partial build test.  I pushed these out in a branch that
> 0-day build and it didn't see any problems.

Applied the lot, thank you.