From d1bc50495597755ac1b511e4b932d19ebab7065f Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 5 Nov 2018 16:51:47 +0100 Subject: [PATCH] mt76: fix building without CONFIG_LEDS_CLASS When CONFIG_LEDS_CLASS is disabled, or it is a loadable module while mt76 is built-in, we run into a link error: drivers/net/wireless/mediatek/mt76/mac80211.o: In function `mt76_register_device': mac80211.c:(.text+0xb78): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `devm_of_led_classdev_register' We don't really need a hard dependency here as the driver can presumably work just fine without LEDs, so this follows the iwlwifi example and adds a separate Kconfig option for the LED support, this will be available whenever it will link, and otherwise the respective code gets left out from the driver object. Fixes: 17f1de56df05 ("mt76: add common code shared between multiple chipsets") Signed-off-by: Arnd Bergmann Signed-off-by: Lorenzo Bianconi Signed-off-by: Kalle Valo --- Makefile | 2 +- mac80211.c | 8 +++++--- mt76x2/pci_init.c | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 18fdf0c6..abe2a4fd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -EXTRA_CFLAGS += -Werror +EXTRA_CFLAGS += -Werror -DCONFIG_MT76_LEDS obj-m := mt76.o obj-$(CONFIG_MT7603E) += mt7603/ diff --git a/mac80211.c b/mac80211.c index d7aad013..2bf3ad07 100644 --- a/mac80211.c +++ b/mac80211.c @@ -347,9 +347,11 @@ int mt76_register_device(struct mt76_dev *dev, bool vht, mt76_check_sband(dev, NL80211_BAND_2GHZ); mt76_check_sband(dev, NL80211_BAND_5GHZ); - ret = mt76_led_init(dev); - if (ret) - return ret; + if (IS_ENABLED(CONFIG_MT76_LEDS)) { + ret = mt76_led_init(dev); + if (ret) + return ret; + } return ieee80211_register_hw(hw); } diff --git a/mt76x2/pci_init.c b/mt76x2/pci_init.c index ad0d090b..34418e57 100644 --- a/mt76x2/pci_init.c +++ b/mt76x2/pci_init.c @@ -405,8 +405,10 @@ int mt76x2_register_device(struct mt76x02_dev *dev) mt76x02_config_mac_addr_list(dev); /* init led callbacks */ - dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness; - dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink; + if (IS_ENABLED(CONFIG_MT76_LEDS)) { + dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness; + dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink; + } ret = mt76_register_device(&dev->mt76, true, mt76x02_rates, ARRAY_SIZE(mt76x02_rates));