[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250214-rtl8366rb-leds-compile-issue-v1-1-c4a82ee68588@linaro.org>
Date: Fri, 14 Feb 2025 09:59:57 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Alvin Šipraga <alsi@...g-olufsen.dk>,
Andrew Lunn <andrew@...n.ch>, Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Luiz Angelo Daros de Luca <luizluca@...il.com>
Cc: netdev@...r.kernel.org, kernel test robot <lkp@...el.com>,
Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH] net: dsa: rtl8366rb: Fix compilation problem
When the kernel is compiled without LED framework support the
rtl8366rb fails to build like this:
rtl8366rb.o: in function `rtl8366rb_setup_led':
rtl8366rb.c:953:(.text.unlikely.rtl8366rb_setup_led+0xe8):
undefined reference to `led_init_default_state_get'
rtl8366rb.c:980:(.text.unlikely.rtl8366rb_setup_led+0x240):
undefined reference to `devm_led_classdev_register_ext'
As this is constantly coming up in different randconfig builds,
bite the bullet and add some nasty ifdefs to rid this issue.
Fixes: 32d617005475 ("net: dsa: realtek: add LED drivers for rtl8366rb")
Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502070525.xMUImayb-lkp@intel.com/
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
drivers/net/dsa/realtek/rtl8366rb.c | 53 +++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c
index 4c4a95d4380ce2a8a88a6d564cc16eab5a82dbc8..b914bb288f864ed211ff0b799d4f1938474199a7 100644
--- a/drivers/net/dsa/realtek/rtl8366rb.c
+++ b/drivers/net/dsa/realtek/rtl8366rb.c
@@ -372,12 +372,14 @@ enum rtl8366_ledgroup_mode {
__RTL8366RB_LEDGROUP_MODE_MAX
};
+#if IS_ENABLED(CONFIG_LEDS_CLASS)
struct rtl8366rb_led {
u8 port_num;
u8 led_group;
struct realtek_priv *priv;
struct led_classdev cdev;
};
+#endif
/**
* struct rtl8366rb - RTL8366RB-specific data
@@ -388,7 +390,9 @@ struct rtl8366rb_led {
struct rtl8366rb {
unsigned int max_mtu[RTL8366RB_NUM_PORTS];
bool pvid_enabled[RTL8366RB_NUM_PORTS];
+#if IS_ENABLED(CONFIG_LEDS_CLASS)
struct rtl8366rb_led leds[RTL8366RB_NUM_PORTS][RTL8366RB_NUM_LEDGROUPS];
+#endif
};
static struct rtl8366_mib_counter rtl8366rb_mib_counters[] = {
@@ -831,6 +835,7 @@ static int rtl8366rb_jam_table(const struct rtl8366rb_jam_tbl_entry *jam_table,
return 0;
}
+/* This code is used also with LEDs disabled */
static int rb8366rb_set_ledgroup_mode(struct realtek_priv *priv,
u8 led_group,
enum rtl8366_ledgroup_mode mode)
@@ -850,6 +855,7 @@ static int rb8366rb_set_ledgroup_mode(struct realtek_priv *priv,
return 0;
}
+#if IS_ENABLED(CONFIG_LEDS_CLASS)
static inline u32 rtl8366rb_led_group_port_mask(u8 led_group, u8 port)
{
switch (led_group) {
@@ -988,26 +994,6 @@ static int rtl8366rb_setup_led(struct realtek_priv *priv, struct dsa_port *dp,
return 0;
}
-static int rtl8366rb_setup_all_leds_off(struct realtek_priv *priv)
-{
- int ret = 0;
- int i;
-
- regmap_update_bits(priv->map,
- RTL8366RB_INTERRUPT_CONTROL_REG,
- RTL8366RB_P4_RGMII_LED,
- 0);
-
- for (i = 0; i < RTL8366RB_NUM_LEDGROUPS; i++) {
- ret = rb8366rb_set_ledgroup_mode(priv, i,
- RTL8366RB_LEDGROUP_OFF);
- if (ret)
- return ret;
- }
-
- return ret;
-}
-
static int rtl8366rb_setup_leds(struct realtek_priv *priv)
{
struct dsa_switch *ds = &priv->ds;
@@ -1039,6 +1025,33 @@ static int rtl8366rb_setup_leds(struct realtek_priv *priv)
}
return 0;
}
+#else
+static int rtl8366rb_setup_leds(struct realtek_priv *priv)
+{
+ return 0;
+}
+#endif
+
+/* This code is used also with LEDs disabled */
+static int rtl8366rb_setup_all_leds_off(struct realtek_priv *priv)
+{
+ int ret = 0;
+ int i;
+
+ regmap_update_bits(priv->map,
+ RTL8366RB_INTERRUPT_CONTROL_REG,
+ RTL8366RB_P4_RGMII_LED,
+ 0);
+
+ for (i = 0; i < RTL8366RB_NUM_LEDGROUPS; i++) {
+ ret = rb8366rb_set_ledgroup_mode(priv, i,
+ RTL8366RB_LEDGROUP_OFF);
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
static int rtl8366rb_setup(struct dsa_switch *ds)
{
---
base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
change-id: 20250213-rtl8366rb-leds-compile-issue-dcd2c3c50fef
Best regards,
--
Linus Walleij <linus.walleij@...aro.org>
Powered by blists - more mailing lists