[PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization
From: Kyle Switch
Date: Fri Sep 04 2026 - 06:14:38 EST
Add a mib_init flag to indicate whether MIB polling has been
successfully initialized. This prevents the driver from attempting
to clean up MIB-related resources on removal for switch families
that do not support MIB polling, which would otherwise trigger
errors or crashes.
Signed-off-by: Kyle Switch <kyle.switch@xxxxxxxxxxxxxx>
---
drivers/net/dsa/motorcomm/chip.c | 2 ++
drivers/net/dsa/motorcomm/chip.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index f74a44048fb1..df5c0b995fde 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -4559,6 +4559,7 @@ static int yt921x_dsa_setup(struct dsa_switch *ds)
pp->index = i;
INIT_DELAYED_WORK(&pp->mib_read, yt921x_poll_mib);
+ pp->mib_init = true;
}
mutex_lock(&priv->reg_lock);
@@ -4771,6 +4772,7 @@ static void yt921x_mdio_remove(struct mdio_device *mdiodev)
for (size_t i = ARRAY_SIZE(priv->ports); i-- > 0; ) {
struct yt921x_port *pp = &priv->ports[i];
+ if (pp->mib_init)
disable_delayed_work_sync(&pp->mib_read);
}
diff --git a/drivers/net/dsa/motorcomm/chip.h b/drivers/net/dsa/motorcomm/chip.h
index 65f9e6234678..6c89e3d304fa 100644
--- a/drivers/net/dsa/motorcomm/chip.h
+++ b/drivers/net/dsa/motorcomm/chip.h
@@ -943,6 +943,7 @@ struct yt921x_port {
struct yt921x_mib mib;
u64 rx_frames;
u64 tx_frames;
+ bool mib_init;
#if IS_ENABLED(CONFIG_NET_DSA_YT921X_LEDS)
unsigned char led_duty;
--
2.25.1