r8169: fix building with CONFIG_LEDS_CLASS=m
Subsystems (4)
PATCH 1/1 r8169: fix building with CONFIG_LEDS_CLASS=m
From: Arnd Bergmann <[email protected]>
When r8169 is built-in but the LED support is a loadable module, the new code to drive the LED now causes a link failure:
ld: drivers/net/ethernet/realtek/r8169_leds.o: in function `rtl8168_init_leds':
r8169_leds.c:(.text+0x36c): undefined reference to `devm_led_classdev_register_ext'
Add a Kconfig dependency to prevent the broken configuration but still allow having the network code built-in as long as CONFIG_LEDS_TRIGGER_NETDEV is disabled, regardless of CONFIG_LEDS_CLASS.
--- drivers/net/ethernet/realtek/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/realtek/Kconfig +1 -0
@@ -98,6 +98,7 @@ config 8139_OLD_RX_RESET config R8169 tristate "Realtek 8169/8168/8101/8125 ethernet support" depends on PCI + depends on LEDS_CLASS || !LEDS_TRIGGER_NETDEV select FW_LOADER select CRC32 select PHYLIB
Signature · 1 line
2.39.2
Heiner Kallweit
maintainerQuoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When r8169 is built-in but the LED support is a loadable module, the new code to drive the LED now causes a link failure:
Quoted 7 lines
ld:
drivers/net/ethernet/realtek/r8169_leds.o: in function `rtl8168_init_leds':
r8169_leds.c:(.text+0x36c): undefined reference to `devm_led_classdev_register_ext'Add a
Kconfigdependency to prevent the broken configuration but still allow having the network code built-in as long asCONFIG_LEDS_TRIGGER_NETDEVis disabled, regardless ofCONFIG_LEDS_CLASS.
The proposed change is more of a workaround IMO. A proper fix (in LED subsystem) has been submitted, but it's not reviewed/applied yet. And I don't think building r8169 should depend on support for an optional feature.
This fix would also allow to remove Kconfig dependencies similar to the one proposed here from other drivers. Link to submitted fix:
https://lore.kernel.org/linux-leds/[email protected]/T/#u
Quoted 18 lines
Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/ethernet/realtek/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/realtek/Kconfig +1
-0@@ -98,6 +98,7 @@ config 8139_OLD_RX_RESET config R8169 tristate "Realtek 8169/8168/8101/8125 ethernet support" depends on PCI + depends on LEDS_CLASS || !LEDS_TRIGGER_NETDEV select FW_LOADER select CRC32 select PHYLIB
Quoted 22 lines · Heiner Kallweit
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When r8169 is built-in but the LED support is a loadable module, the new code to drive the LED now causes a link failure:
Quoted 7 lines
ld:
drivers/net/ethernet/realtek/r8169_leds.o: in function `rtl8168_init_leds':
r8169_leds.c:(.text+0x36c): undefined reference to `devm_led_classdev_register_ext'Add a
Kconfigdependency to prevent the broken configuration but still allow having the network code built-in as long asCONFIG_LEDS_TRIGGER_NETDEVis disabled, regardless ofCONFIG_LEDS_CLASS.The proposed change is more of a workaround IMO. A proper fix (in LED subsystem)
has been submitted, but it's not reviewed/applied yet. And I don't think building
r8169 should depend on support for an optional feature.
This fix would also allow to removeKconfigdependencies similar to the one
proposed here from other drivers. Link to submitted fix:
I think that is a much worse workaround, as this just leads to a feature silently not working even when it is enabled (as loadable module), and hiding other dependency problems where drivers actually require the LED support to do something useful.
IS_REACHABLE() is pretty much always a bad idea because of this.
If you want the LED support in r8169_leds to be optional, I would suggest adding a separate Kconfig symbol for that, either user visible or hidden, and have the correct Kconfig dependencies for the new symbol, something like the change below (untested).
Arnd
8<---
drivers/net/ethernet/realtek/Kconfig +5 -0
@@ -114,4 +114,9 @@ config R8169 To compile this driver as a module, choose M here: the module will be called r8169. This is recommended. +config R8169_LEDS + def_bool y + depends on LEDS_TRIGGER_NETDEV && R8169 + depends on !(R8169=y && LEDS_CLASS=m) + endif # NET_VENDOR_REALTEK
drivers/net/ethernet/realtek/Makefile +2 -4
@@ -6,8 +6,6 @@ obj-$(CONFIG_8139CP) += 8139cp.o obj-$(CONFIG_8139TOO) += 8139too.o obj-$(CONFIG_ATP) += atp.o -r8169-objs += r8169_main.o r8169_firmware.o r8169_phy_config.o -ifdef CONFIG_LEDS_TRIGGER_NETDEV -r8169-objs += r8169_leds.o -endif +r8169-y += r8169_main.o r8169_firmware.o r8169_phy_config.o +r8169-$(CONFIG_R8169_LEDS) += r8169_leds.o obj-$(CONFIG_R8169) += r8169.o
drivers/net/ethernet/realtek/r8169_main.c +2 -3
@@ -5356,11 +5356,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc)return rc; -#if IS_REACHABLE (CONFIG_LEDS_CLASS ) &&IS_ENABLED (CONFIG_LEDS_TRIGGER_NETDEV ) -if (tp->mac_version >RTL_GIGA_MAC_VER_06 && +if (IS_ENABLED (CONFIG_R8169_LEDS ) && + tp->mac_version >RTL_GIGA_MAC_VER_06 && tp->mac_version <RTL_GIGA_MAC_VER_61 )rtl8168_init_leds (dev); -#endif netdev_info (dev,"%s, %pM, XID %03x, IRQ %d\n" , rtl_chip_infos[chipset].name, dev->dev_addr, xid, tp->irq);
Heiner Kallweit
maintainerQuoted 23 lines · Arnd Bergmann
Quoted 22 lines · Heiner Kallweit
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When r8169 is built-in but the LED support is a loadable module, the new code to drive the LED now causes a link failure:
Quoted 7 lines
ld:
drivers/net/ethernet/realtek/r8169_leds.o: in function `rtl8168_init_leds':
r8169_leds.c:(.text+0x36c): undefined reference to `devm_led_classdev_register_ext'Add a
Kconfigdependency to prevent the broken configuration but still allow having the network code built-in as long asCONFIG_LEDS_TRIGGER_NETDEVis disabled, regardless ofCONFIG_LEDS_CLASS.The proposed change is more of a workaround IMO. A proper fix (in LED subsystem)
has been submitted, but it's not reviewed/applied yet. And I don't think building
r8169 should depend on support for an optional feature.
This fix would also allow to removeKconfigdependencies similar to the one
proposed here from other drivers. Link to submitted fix:
Quoted 7 lines
I think that is a much worse workaround, as this just leads to a feature silently not working even when it is enabled (as loadable module), and hiding other dependency problems where drivers actually require the LED support to do something useful.
Whether implicit dependency detection is considered a bad thing, may depend on personal taste. However I see your point.
Quoted 7 lines
IS_REACHABLE()is pretty much always a bad idea because of this.If you want the LED support in
r8169_ledsto be optional, I would suggest adding a separateKconfigsymbol for that, either user visible or hidden, and have the correctKconfigdependencies for the new symbol, something like the change below (untested).
Sounds good, as this would also allow to omit compiling r8169_leds.c if LEDS_CLASS isn't reachable. I'll give it a try.
Quoted 2 lines
Arnd
Heiner
Quoted 48 lines
8<---
drivers/net/ethernet/realtek/Kconfig +5
-0@@ -114,4 +114,9 @@ config R8169 To compile this driver as a module, choose M here: the module will be called r8169. This is recommended. +config R8169_LEDS + def_bool y + depends on LEDS_TRIGGER_NETDEV && R8169 + depends on !(R8169=y && LEDS_CLASS=m) + endif # NET_VENDOR_REALTEKdrivers/net/ethernet/realtek/Makefile +2
-4@@ -6,8 +6,6 @@ obj-$(CONFIG_8139CP) += 8139cp.o obj-$(CONFIG_8139TOO) += 8139too.o obj-$(CONFIG_ATP) += atp.o -r8169-objs += r8169_main.o r8169_firmware.o r8169_phy_config.o -ifdef CONFIG_LEDS_TRIGGER_NETDEV -r8169-objs += r8169_leds.o -endif +r8169-y += r8169_main.o r8169_firmware.o r8169_phy_config.o +r8169-$(CONFIG_R8169_LEDS) += r8169_leds.o obj-$(CONFIG_R8169) += r8169.odrivers/net/ethernet/realtek/r8169_main.c +2
-3@@ -5356,11 +5356,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc)return rc; -#if IS_REACHABLE (CONFIG_LEDS_CLASS ) &&IS_ENABLED (CONFIG_LEDS_TRIGGER_NETDEV ) -if (tp->mac_version >RTL_GIGA_MAC_VER_06 && +if (IS_ENABLED (CONFIG_R8169_LEDS ) && + tp->mac_version >RTL_GIGA_MAC_VER_06 && tp->mac_version <RTL_GIGA_MAC_VER_61 )rtl8168_init_leds (dev); -#endif netdev_info (dev,"%s, %pM, XID %03x, IRQ %d\n" , rtl_chip_infos[chipset].name, dev->dev_addr, xid, tp->irq);