From 85961cc7987a00ae29a1508a99e173d761fcd812 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Sun, 29 Mar 2026 19:55:34 +0200 Subject: [PATCH] realtek: dsa: drop port_width from instance structure The port_width attribute is only used once and can be derived from the cpu_port. Drop it. Add a comment for better readability. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22438 Signed-off-by: Hauke Mehrtens --- .../linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c | 4 ---- target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c | 3 ++- .../realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c index aae7261f68..866728785e 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c @@ -1610,7 +1610,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) case RTL8380_FAMILY_ID: priv->ds->ops = &rtldsa_83xx_switch_ops; priv->ds->phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops; - priv->port_width = 1; priv->fib_entries = 8192; priv->ds->num_lag_ids = 8; priv->l2_bucket_size = 4; @@ -1619,7 +1618,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) case RTL8390_FAMILY_ID: priv->ds->ops = &rtldsa_83xx_switch_ops; priv->ds->phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops; - priv->port_width = 2; priv->fib_entries = 16384; priv->ds->num_lag_ids = 16; priv->l2_bucket_size = 4; @@ -1628,7 +1626,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) case RTL9300_FAMILY_ID: priv->ds->ops = &rtldsa_93xx_switch_ops; priv->ds->phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops; - priv->port_width = 1; priv->fib_entries = 16384; priv->ds->num_lag_ids = 16; sw_w32(0, RTL930X_ST_CTRL); @@ -1638,7 +1635,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) case RTL9310_FAMILY_ID: priv->ds->ops = &rtldsa_93xx_switch_ops; priv->ds->phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops; - priv->port_width = 2; priv->fib_entries = 16384; priv->ds->num_lag_ids = 16; sw_w32(0, RTL931x_ST_CTRL); diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c index b6742e36b1..04ae433df5 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c @@ -1452,10 +1452,11 @@ static void rtldsa_port_xstp_state_set(struct rtl838x_switch_priv *priv, int por u8 state, u16 mst_slot) __must_hold(&priv->reg_mutex) { + /* 838x/930x have 28 ports and 2 bit fields other devices 4 bit fields. */ + int n = priv->r->cpu_port == RTL838X_CPU_PORT ? 2 : 4; u32 port_state[4]; int index, bit; int pos = port; - int n = priv->port_width << 1; /* Ports above or equal CPU port can never be configured */ if (port >= priv->r->cpu_port) diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h index fdf8418700..e62abfdf20 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1516,7 +1516,6 @@ struct rtl838x_switch_priv { int mirror_group_ports[4]; struct mii_bus *parent_bus; const struct rtldsa_config *r; - u8 port_width; u64 irq_mask; u32 fib_entries; int l2_bucket_size;