[PATCH net 5/6] net: dsa: ksz: fix wrong pvid

From: Gilles DOFFE
Date: Wed Jan 13 2021 - 07:56:10 EST


A logical 'or' was performed until now.
So if vlan 1 is the current pvid and vlan 20 is set as the new one,
vlan 21 is the new pvid.
This commit fixes this by setting the right mask to set the new pvid.

Signed-off-by: Gilles DOFFE <gilles.doffe@xxxxxxxxxxxxxxxxxxxx>
---
drivers/net/dsa/microchip/ksz8795.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index b55fb2761993..44306a7e297a 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -868,8 +868,8 @@ static void ksz8795_port_vlan_add(struct dsa_switch *ds, int port,

if (new_pvid) {
ksz_pread16(dev, port, REG_PORT_CTRL_VID, &vid);
- vid &= 0xfff;
- vid |= new_pvid;
+ vid &= ~0xfff;
+ vid |= (new_pvid & 0xfff);
ksz_pwrite16(dev, port, REG_PORT_CTRL_VID, vid);
}

--
2.25.1