Skip to content

mt76: pass CONFIG_MT76_LEDS define to subdirectory drivers - #1131

Open
EmreYavuzalp wants to merge 1 commit into
openwrt:masterfrom
EmreYavuzalp:led-subdir-ccflags
Open

EmreYavuzalp wants to merge 1 commit into
openwrt:masterfrom
EmreYavuzalp:led-subdir-ccflags

Conversation

@EmreYavuzalp

Copy link
Copy Markdown

The -DCONFIG_MT76_LEDS define is added via ccflags-y, which only affects objects compiled in the top-level directory. Per-chip drivers built from a subdirectory (obj-$(CONFIG_MT7603E) += mt7603/, and the other subdirectories) are therefore compiled without the define.

For those drivers IS_ENABLED(CONFIG_MT76_LEDS) evaluates to false, so the leds.cdev.brightness_set / blink_set callbacks are never installed; mt76_led_init() then returns early and the LED class device (mt76-phyN) is never registered.

On a dual-band board the effect is asymmetric: the 5 GHz LED works (mt76x2's callback is set in the top-level mt76x02_util.c, which gets the define) while the 2.4 GHz LED does not (mt7603's callback is set in mt7603/init.c, which does not). Observed on a TP-Link Archer C5v (mt7603 + mt76x2): only mt76-phy1 registered, mt76-phy0 was missing.

Add the define via subdir-ccflags-y as well, which applies to the current directory and all subdirectories, so the per-chip drivers get it too. -Werror is intentionally left in ccflags-y (top level only) so it is not forced onto the subdirectory builds.

Comment thread Makefile
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause-Clear
ccflags-y += -Werror -DCONFIG_MT76_LEDS
subdir-ccflags-y += -DCONFIG_MT76_LEDS

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can drop all other -DCONFIG_MT76_LEDS after this change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, consolidated into a single subdir-ccflags-y += -DCONFIG_MT76_LEDS and dropped all the now-redundant per-directory -DCONFIG_MT76_LEDS (top Makefile + mt7603/mt7615/mt7915/mt7996). -Werror left unchanged. Thanks!

CONFIG_MT76_LEDS was passed with -DCONFIG_MT76_LEDS in ccflags-y, which
only affects the directory it is written in. It was therefore repeated in
the top-level Makefile and in several per-chip subdirectory Makefiles
(mt7603, mt7615, mt7915, mt7996) -- but not consistently, so a driver
built from a subdirectory that relied on it could still be compiled with
IS_ENABLED(CONFIG_MT76_LEDS) false: mt76_led_init() then returns early and
the LED class device (mt76-phyN) is never registered.

On a dual-band board the effect was asymmetric: the 5 GHz LED worked
(mt76x2's callback is set in the top-level mt76x02_util.c, which had the
define) while the 2.4 GHz LED did not (mt7603's callback is set in
mt7603/init.c). Observed on a TP-Link Archer C5v (mt7603 + mt76x2): only
mt76-phy1 registered, mt76-phy0 was missing.

Define it once via subdir-ccflags-y in the top-level Makefile, which
applies to the current directory and all subdirectories, and drop the now
redundant per-directory -DCONFIG_MT76_LEDS. -Werror is left unchanged.

Signed-off-by: Emre Yavuzalp <emreyavuzalp2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants