Skip to contentSkip to conversation

platform/chrome: cros_kbd_led_backlight: fix build warning

PATCH Applied Tzung-Bi Shih 3 participants 6 messages Jul 18, 2022 – Jul 21, 2022

Subsystems (2)
lore
Share & tools
lore

Tzung-Bi Shih

author maintainer
#0 lore raw

PATCH v2 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 using __maybe_unused. Also use IS_ENABLED() because CROS_EC is 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")

---
Changes from v1 (https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/):
- Use __maybe_unused.

 drivers/platform/chrome/cros_kbd_led_backlight.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/chrome/cros_kbd_led_backlight.c +5 -5
index 5ad41c10412d..793fd3f1015d 100644
@@ -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)
 
 static int
 keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
@@ -180,18 +180,18 @@ static int keyboard_led_init_ec_pwm(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {
+static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {
 	.init = keyboard_led_init_ec_pwm,
 	.brightness_set_blocking = keyboard_led_set_brightness_ec_pwm,
 	.brightness_get = keyboard_led_get_brightness_ec_pwm,
 	.max_brightness = KEYBOARD_BACKLIGHT_MAX,
 };
 
-#else /* CONFIG_CROS_EC */
+#else /* IS_ENABLED(CONFIG_CROS_EC) */
 
-static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {};
+static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {};
 
-#endif /* CONFIG_CROS_EC */
+#endif /* IS_ENABLED(CONFIG_CROS_EC) */
 
 static int keyboard_led_probe(struct platform_device *pdev)
 {
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
#1 lore raw
Quoted 12 lines · Tzung-Bi Shih

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/

Quoted 2 lines

Fix the warning by using __maybe_unused. Also use IS_ENABLED() because CROS_EC is a tristate.

Is that sufficient ? What happens if CROS_KBD_LED_BACKLIGHT=y and CROS_EC=m ? I suspect you might need IS_REACHABLE() instead of IS_ENABLED().

Thanks,
Guenter

Quoted 52 lines

[1]: https://download.01.org/0day-ci/archive/20220717/[email protected]/config

Fixes 40f58143745e ("platform/chrome: cros_kbd_led_backlight: support EC PWM backend")

---
Changes from v1 (https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/):
- Use __maybe_unused.

 drivers/platform/chrome/cros_kbd_led_backlight.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/chrome/cros_kbd_led_backlight.c +5 -6
index 5ad41c10412d..793fd3f1015d 100644
@@ -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)
 
 static int
 keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
@@ -180,18 +180,18 @@ static int keyboard_led_init_ec_pwm(struct platform_device *pdev)
        return 0;
 }
 
-static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {
+static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {
        .init = keyboard_led_init_ec_pwm,
        .brightness_set_blocking = keyboard_led_set_brightness_ec_pwm,
        .brightness_get = keyboard_led_get_brightness_ec_pwm,
        .max_brightness = KEYBOARD_BACKLIGHT_MAX,
 };
 
-#else /* CONFIG_CROS_EC */
+#else /* IS_ENABLED(CONFIG_CROS_EC) */
 
-static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {};
+static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {};
 
-#endif /* CONFIG_CROS_EC */
+#endif /* IS_ENABLED(CONFIG_CROS_EC) */
 
 static int keyboard_led_probe(struct platform_device *pdev)
 {
--

2.37.0.170.g444d1eabd0-goog

author maintainer
#2 lore raw
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Tzung-Bi Shih

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/

Quoted 6 lines
Quoted 2 lines

Fix the warning by using __maybe_unused. Also use IS_ENABLED() because CROS_EC is a tristate.

Is that sufficient ? What happens if CROS_KBD_LED_BACKLIGHT=y and CROS_EC=m ? I suspect you might need IS_REACHABLE() instead of IS_ENABLED().

For current code, it's impossible to set CROS_KBD_LED_BACKLIGHT=y and CROS_EC=m without setting ACPI=y. Given that the dependencies:
CHROME_PLATFORMS [=y] && LEDS_CLASS [=y] && (ACPI [=n] || CROS_EC [=m]).

$ ./scripts/kconfig/merge_config.sh -n <(cat <<EOF
CONFIG_MODULES=y

CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y

CONFIG_CHROME_PLATFORMS=y
CONFIG_CROS_EC=m
CONFIG_CROS_KBD_LED_BACKLIGHT=y
EOF
)
[...]
Value requested for CONFIG_CROS_KBD_LED_BACKLIGHT not in final .config

Requested value:  CONFIG_CROS_KBD_LED_BACKLIGHT=y
Actual value:     CONFIG_CROS_KBD_LED_BACKLIGHT=m

However, when ACPI=y, keyboard_led_drvdata_ec_pwm is unused. Instead, it uses keyboard_led_drvdata_acpi for current code.

I guess IS_ENABLED() is sufficient. Does it make sense?

Reviewed-by
#3 lore raw
Quoted 39 lines · Tzung-Bi Shih
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Tzung-Bi Shih

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/

Quoted 6 lines
Quoted 2 lines

Fix the warning by using __maybe_unused. Also use IS_ENABLED() because CROS_EC is a tristate.

Is that sufficient ? What happens if CROS_KBD_LED_BACKLIGHT=y and CROS_EC=m ? I suspect you might need IS_REACHABLE() instead of IS_ENABLED().

For current code, it's impossible to set CROS_KBD_LED_BACKLIGHT=y and CROS_EC=m without setting ACPI=y. Given that the dependencies:
CHROME_PLATFORMS [=y] && LEDS_CLASS [=y] && (ACPI [=n] || CROS_EC [=m]).

$ ./scripts/kconfig/merge_config.sh -n <(cat <<EOF
CONFIG_MODULES=y

CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y

CONFIG_CHROME_PLATFORMS=y
CONFIG_CROS_EC=m
CONFIG_CROS_KBD_LED_BACKLIGHT=y
EOF
)
[...]
Value requested for CONFIG_CROS_KBD_LED_BACKLIGHT not in final .config

Quoted 3 lines
Requested value:  CONFIG_CROS_KBD_LED_BACKLIGHT=y
Actual value:     CONFIG_CROS_KBD_LED_BACKLIGHT=m

It is actually possible to configure CONFIG_CROS_KBD_LED_BACKLIGHT=y with CONFIG_CROS_EC=m, by also setting CONFIG_LEDS_CLASS=y. However, that doesn't seem to matter since the critical symbol is CROS_EC_PROTO which is boolean.
Given that, IS_ENABLED should be fine.

Thanks,
Guenter

Quoted 4 lines

However, when ACPI=y, keyboard_led_drvdata_ec_pwm is unused. Instead, it uses keyboard_led_drvdata_acpi for current code.

I guess IS_ENABLED() is sufficient. Does it make sense?

#4 lore raw
In reply to Tzung-Bi Shih
This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Quoted 4 lines · On Mon, 18 Jul 2022 10:50:47 +0000 you wrote:

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'

Quoted 8 lines

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/

[...]

Here is the summary with links:
- [v2] platform/chrome: cros_kbd_led_backlight: fix build warning

    https://git.kernel.org/chrome-platform/c/7e76e4bc0099

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#5 lore raw
In reply to Tzung-Bi Shih
This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Quoted 4 lines · On Mon, 18 Jul 2022 10:50:47 +0000 you wrote:

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'

Quoted 8 lines

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/

[...]

Here is the summary with links:
- [v2] platform/chrome: cros_kbd_led_backlight: fix build warning

    https://git.kernel.org/chrome-platform/c/7e76e4bc0099

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html