platform/chrome: cros_kbd_led_backlight: fix build warning
Subsystems (2)
Tzung-Bi Shih
maintainerPATCH 1/1 platform/chrome: cros_kbd_led_backlight: fix build warning
drivers/platform/chrome/cros_kbd_led_backlight.c got a new build warning when using the randconfig in [1]:
Quoted 1 line
Quoted 1 line
Quoted 1 line
warning: unused variable '
keyboard_led_drvdata_ec_pwm'
The warning happens when CONFIG_CROS_EC is set but CONFIG_OF is not set. Reproduce:
- mkdir build_dir
- wget [1] -O build_dir/.config
- COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 \
O=build_dir ARCH=s390 SHELL=/bin/bash drivers/platform/chrome/
Fix the warning by hardening the guard condition. Also use IS_ENABLED() because CROS_EC is a tristate.
[1]: https://download.01.org/0day-ci/archive/20220717/[email protected]/config
--- drivers/platform/chrome/cros_kbd_led_backlight.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/chrome/cros_kbd_led_backlight.c +2 -6
@@ -119,7 +119,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {#endif /* CONFIG_ACPI */ -#ifdef CONFIG_CROS_EC +#if IS_ENABLED (CONFIG_CROS_EC ) && defined(CONFIG_OF ) static int keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
@@ -187,11 +187,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = { .max_brightness = KEYBOARD_BACKLIGHT_MAX, }; -#else /* CONFIG_CROS_EC */ - -static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {}; - -#endif /* CONFIG_CROS_EC */ +#endif /* IS_ENABLED(CONFIG_CROS_EC) && defined(CONFIG_OF) */ static int keyboard_led_probe (struct platform_device *pdev) {
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
Quoted 12 lines · Tzung-Bi Shih
drivers/platform/chrome/cros_kbd_led_backlight.cgot a new build warning when using the randconfig in [1]:Quoted 1 line
Quoted 1 line
Quoted 1 line
warning: unused variable '
keyboard_led_drvdata_ec_pwm'The warning happens when
CONFIG_CROS_ECis set butCONFIG_OFis not set. Reproduce:
- mkdirbuild_dir
- wget [1] -O build_dir/.config
- COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 \
O=build_dir ARCH=s390 SHELL=/bin/bashdrivers/platform/chrome/
Have you tried the following ?
CONFIG_ACPI=y
CONFIG_CROS_EC=n
CONFIG_OF=y
That should be possible, but with your patch it should now result in a build error because keyboard_led_drvdata_ec_pwm is no longer defined.
Also, with your patch, CONFIG_CROS_EC=y, CONFIG_ACPI=y, and CONFIG_OF=n (ie Intel/AMD systems) would result in the code not being compiled, which would be wrong.
Thanks,
Guenter
Quoted 41 lines
Fix the warning by hardening the guard condition. Also use
IS_ENABLED()becauseCROS_ECis a tristate.[1]: https://download.01.org/0day-ci/archive/20220717/[email protected]/config
Fixes 40f58143745e ("platform/chrome: cros_kbd_led_backlight: support EC PWM backend")Reported-by kernel test robot <[email protected]>Signed-off-by Tzung-Bi Shih <[email protected]>--- drivers/platform/chrome/cros_kbd_led_backlight.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/platform/chrome/cros_kbd_led_backlight.c +2
-7@@ -119,7 +119,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {#endif /* CONFIG_ACPI */ -#ifdef CONFIG_CROS_EC +#if IS_ENABLED (CONFIG_CROS_EC ) && defined(CONFIG_OF ) static int keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,@@ -187,11 +187,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = { .max_brightness = KEYBOARD_BACKLIGHT_MAX, }; -#else /* CONFIG_CROS_EC */ - -static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {}; - -#endif /* CONFIG_CROS_EC */ +#endif /* IS_ENABLED(CONFIG_CROS_EC) && defined(CONFIG_OF) */ static int keyboard_led_probe (struct platform_device *pdev) { --2.37.0.170.g444d1eabd0-goog
Tzung-Bi Shih
maintainerQuoted 14 lines · Guenter Roeck
Quoted 12 lines · Tzung-Bi Shih
drivers/platform/chrome/cros_kbd_led_backlight.cgot a new build warning when using the randconfig in [1]:Quoted 1 line
Quoted 1 line
Quoted 1 line
warning: unused variable '
keyboard_led_drvdata_ec_pwm'The warning happens when
CONFIG_CROS_ECis set butCONFIG_OFis not set. Reproduce:
- mkdirbuild_dir
- wget [1] -O build_dir/.config
- COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 \
O=build_dir ARCH=s390 SHELL=/bin/bashdrivers/platform/chrome/
Quoted 7 lines
Have you tried the following ?
CONFIG_ACPI=y
CONFIG_CROS_EC=n
CONFIG_OF=yThat should be possible, but with your patch it should now result in a build error because
keyboard_led_drvdata_ec_pwmis no longer defined.
Hmm, just got another lkp robot's warning about the undeclared symbol. Will fix it by using __maybe_unused in next version.
Quoted 3 lines
Also, with your patch,
CONFIG_CROS_EC=y,CONFIG_ACPI=y, andCONFIG_OF=n(ie Intel/AMD systems) would result in the code not being compiled, which would be wrong.
Intel and AMD systems rely on keyboard_led_drvdata_acpi but not keyboard_led_drvdata_ec_pwm for now. They shouldn't be affected by the patch.
In any cases, let's use __maybe_unused in next version.