Skip to contentSkip to conversation

r8169: fix building with CONFIG_LEDS_CLASS=m

PATCH Applied Heiner Kallweit 4 participants 4 messages Jan 3, 2024 – Jan 5, 2024

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 r8169: fix building with CONFIG_LEDS_CLASS=m

When r8169 is built-in but LED support is a loadable module, the new code to drive the LED 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'

LED support is an optional feature, so fix this issue by adding a Kconfig symbol R8169_LEDS that is guaranteed to be false if r8169 is built-in and LED core support is a module. As a positive side effect of this change r8169_leds.o no longer is built under this configuration.

Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")
---
 drivers/net/ethernet/realtek/Kconfig      | 7 +++++++
 drivers/net/ethernet/realtek/Makefile     | 6 ++----
 drivers/net/ethernet/realtek/r8169_main.c | 5 ++---
 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/realtek/Kconfig +7 -0
index 93d9df55b..03015b665 100644
@@ -113,4 +113,11 @@ 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 R8169 && LEDS_TRIGGER_NETDEV
+	depends on !(R8169=y && LEDS_CLASS=m)
+	help
+	  Optional support for controlling the NIC LED's with the netdev
+	  LED trigger.
+
 endif # NET_VENDOR_REALTEK
drivers/net/ethernet/realtek/Makefile +2 -4
index adff9ebfb..635491d88 100644
@@ -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
index c6492096a..349afb157 100644
@@ -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);
Signature · 1 line
2.43.0
reviewer Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Heiner Kallweit

When r8169 is built-in but LED support is a loadable module, the new code to drive the LED 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'

LED support is an optional feature, so fix this issue by adding a Kconfig symbol R8169_LEDS that is guaranteed to be false if r8169 is built-in and LED core support is a module. As a positive side effect of this change r8169_leds.o no longer is built under this configuration.

Quoted 5 lines
Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")

...

Tested-by on v1 1/1
#2 lore raw
In reply to Heiner Kallweit
Quoted 13 lines · Heiner Kallweit

When r8169 is built-in but LED support is a loadable module, the new code to drive the LED 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'

LED support is an optional feature, so fix this issue by adding a Kconfig symbol R8169_LEDS that is guaranteed to be false if r8169 is built-in and LED core support is a module. As a positive side effect of this change r8169_leds.o no longer is built under this configuration.

Quoted 6 lines
Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

This has survived a day of randconfig builds

#3 lore raw
In reply to Heiner Kallweit
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 6 lines · On Wed, 3 Jan 2024 16:52:04 +0100 you wrote:

When r8169 is built-in but LED support is a loadable module, the new code to drive the LED 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'

Quoted 6 lines

LED support is an optional feature, so fix this issue by adding a Kconfig symbol R8169_LEDS that is guaranteed to be false if r8169 is built-in and LED core support is a module. As a positive side effect of this change r8169_leds.o no longer is built under this configuration.

[...]

Here is the summary with links:
- [net-next] r8169: fix building with CONFIG_LEDS_CLASS=m

    https://git.kernel.org/netdev/net-next/c/a2634a5ffcaf

You are awesome, thank you!

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