Skip to content

Commit 5da9603

Browse files
viviendavem330
authored andcommitted
net: dsa: mv88e6xxx: read then write PVID
The port register 0x07 contains more options than just the default VID, even though they are not used yet. So prefer a read then write operation over a direct write. This also allows to keep track of the change through dynamic debug. Signed-off-by: Vivien Didelot <[email protected]> Tested-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d9deae commit 5da9603

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

drivers/net/dsa/mv88e6xxx.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,23 +1166,45 @@ int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
11661166
return 0;
11671167
}
11681168

1169-
static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
1169+
static int _mv88e6xxx_port_pvid(struct dsa_switch *ds, int port, u16 *new,
1170+
u16 *old)
11701171
{
1172+
u16 pvid;
11711173
int ret;
11721174

11731175
ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN);
11741176
if (ret < 0)
11751177
return ret;
11761178

1177-
*pvid = ret & PORT_DEFAULT_VLAN_MASK;
1179+
pvid = ret & PORT_DEFAULT_VLAN_MASK;
1180+
1181+
if (new) {
1182+
ret &= ~PORT_DEFAULT_VLAN_MASK;
1183+
ret |= *new & PORT_DEFAULT_VLAN_MASK;
1184+
1185+
ret = _mv88e6xxx_reg_write(ds, REG_PORT(port),
1186+
PORT_DEFAULT_VLAN, ret);
1187+
if (ret < 0)
1188+
return ret;
1189+
1190+
netdev_dbg(ds->ports[port], "DefaultVID %d (was %d)\n", *new,
1191+
pvid);
1192+
}
1193+
1194+
if (old)
1195+
*old = pvid;
11781196

11791197
return 0;
11801198
}
11811199

1200+
static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
1201+
{
1202+
return _mv88e6xxx_port_pvid(ds, port, NULL, pvid);
1203+
}
1204+
11821205
static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid)
11831206
{
1184-
return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_DEFAULT_VLAN,
1185-
pvid & PORT_DEFAULT_VLAN_MASK);
1207+
return _mv88e6xxx_port_pvid(ds, port, &pvid, NULL);
11861208
}
11871209

11881210
static int _mv88e6xxx_vtu_wait(struct dsa_switch *ds)

0 commit comments

Comments
 (0)