diff mbox series

[04/11] net: dsa: microchip: ksz8795: use reg_mib_cnt where possible

Message ID 20201118220357.22292-5-m.grzeschik@pengutronix.de
State Superseded
Headers show
Series None | expand

Commit Message

Michael Grzeschik Nov. 18, 2020, 10:03 p.m. UTC
The extra define SWITCH_COUNTER_NUM is a copy of the KSZ8795_COUNTER_NUM
define. This patch initializes reg_mib_cnt with KSZ8795_COUNTER_NUM,
makes use of reg_mib_cnt everywhere instead and removes the extra
define.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz8795.c     | 6 +++---
 drivers/net/dsa/microchip/ksz8795_reg.h | 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Andrew Lunn Nov. 19, 2020, 12:16 a.m. UTC | #1
On Wed, Nov 18, 2020 at 11:03:50PM +0100, Michael Grzeschik wrote:
> The extra define SWITCH_COUNTER_NUM is a copy of the KSZ8795_COUNTER_NUM

> define. This patch initializes reg_mib_cnt with KSZ8795_COUNTER_NUM,

> makes use of reg_mib_cnt everywhere instead and removes the extra

> define.

> 

> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
Florian Fainelli Nov. 19, 2020, 3:08 a.m. UTC | #2
On 11/18/2020 2:03 PM, Michael Grzeschik wrote:
> The extra define SWITCH_COUNTER_NUM is a copy of the KSZ8795_COUNTER_NUM

> define. This patch initializes reg_mib_cnt with KSZ8795_COUNTER_NUM,

> makes use of reg_mib_cnt everywhere instead and removes the extra

> define.

> 

> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>


Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

-- 
Florian
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 1164c745ce940d0..04a571bde7e6a4f 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -125,7 +125,7 @@  static void ksz8795_r_mib_cnt(struct ksz_device *dev, int port, u16 addr,
 	u8 check;
 	int loop;
 
-	ctrl_addr = addr + SWITCH_COUNTER_NUM * port;
+	ctrl_addr = addr + dev->reg_mib_cnt * port;
 	ctrl_addr |= IND_ACC_TABLE(TABLE_MIB | TABLE_READ);
 
 	mutex_lock(&dev->alu_mutex);
@@ -156,7 +156,7 @@  static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
 	u8 check;
 	int loop;
 
-	addr -= SWITCH_COUNTER_NUM;
+	addr -= dev->reg_mib_cnt;
 	ctrl_addr = (KS_MIB_TOTAL_RX_1 - KS_MIB_TOTAL_RX_0) * port;
 	ctrl_addr += addr + KS_MIB_TOTAL_RX_0;
 	ctrl_addr |= IND_ACC_TABLE(TABLE_MIB | TABLE_READ);
@@ -1235,7 +1235,7 @@  static int ksz8795_switch_init(struct ksz_device *dev)
 	dev->port_mask = BIT(dev->port_cnt) - 1;
 	dev->port_mask |= dev->host_mask;
 
-	dev->reg_mib_cnt = SWITCH_COUNTER_NUM;
+	dev->reg_mib_cnt = KSZ8795_COUNTER_NUM;
 	dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM;
 
 	dev->mib_port_cnt = TOTAL_PORT_NUM;
diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h
index 3a50462df8fa9d2..25840719b936650 100644
--- a/drivers/net/dsa/microchip/ksz8795_reg.h
+++ b/drivers/net/dsa/microchip/ksz8795_reg.h
@@ -854,7 +854,6 @@ 
 #define KSZ8795_COUNTER_NUM		0x20
 #define TOTAL_KSZ8795_COUNTER_NUM	(KSZ8795_COUNTER_NUM + 4)
 
-#define SWITCH_COUNTER_NUM		KSZ8795_COUNTER_NUM
 #define TOTAL_SWITCH_COUNTER_NUM	TOTAL_KSZ8795_COUNTER_NUM
 
 /* Common names used by other drivers */