To get the driver working with other chips using different port counts
the dyn_mac_table should be flushed depending on the amount of available
ports. This patch remove the extra define TOTOAL_PORT_NUM and is
making use of the dynamic port_cnt variable instead.

Reviewed-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>

---
v1:       - based on "[PATCH v4 05/11] net: dsa: microchip: ksz8795: dynamica 
allocate memory for flush_dyn_mac_table"
          - lore: 
https://lore.kernel.org/netdev/20200803054442.20089-6-m.grzesc...@pengutronix.de/
v1 -> v2: - renamed patch to clarify the purpose
            - based on: 
https://lore.kernel.org/netdev/20201118220357.22292-11-m.grzesc...@pengutronix.de/
          - using DSA_MAX_PORTS instead of dynamic kzalloc allocation
          - improved patch description
---
 drivers/net/dsa/microchip/ksz8795.c     | 4 ++--
 drivers/net/dsa/microchip/ksz8795_reg.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8795.c 
b/drivers/net/dsa/microchip/ksz8795.c
index 7b5c9283712e4..b13ac57ab8bba 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -751,11 +751,11 @@ static void ksz8795_port_stp_state_set(struct dsa_switch 
*ds, int port,
 
 static void ksz8795_flush_dyn_mac_table(struct ksz_device *dev, int port)
 {
-       u8 learn[TOTAL_PORT_NUM];
+       u8 learn[DSA_MAX_PORTS];
        int first, index, cnt;
        struct ksz_port *p;
 
-       if ((uint)port < TOTAL_PORT_NUM) {
+       if ((uint)port < dev->port_cnt) {
                first = port;
                cnt = port + 1;
        } else {
diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h 
b/drivers/net/dsa/microchip/ksz8795_reg.h
index 6377165a236fd..681d19ab27b89 100644
--- a/drivers/net/dsa/microchip/ksz8795_reg.h
+++ b/drivers/net/dsa/microchip/ksz8795_reg.h
@@ -846,8 +846,6 @@
 
 #define KS_PRIO_IN_REG                 4
 
-#define TOTAL_PORT_NUM                 5
-
 #define KSZ8795_COUNTER_NUM            0x20
 
 /* Common names used by other drivers */
-- 
2.29.2

Reply via email to