aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2016-03-07 18:24:39 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-10 16:10:30 -0500
commit5da96031834a65e064b97c8d9f7df958c818a4cc (patch)
tree773c3913e051096a9972e5403caab66c47388a26 /drivers/net/dsa
parent2d9deae4aedee2be2205e22440ac357c37013658 (diff)
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 <vivien.didelot@savoirfairelinux.com> Tested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r--drivers/net/dsa/mv88e6xxx.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 3a58a8afe537..1aee42d1c5f2 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1166,23 +1166,45 @@ int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
1166 return 0; 1166 return 0;
1167} 1167}
1168 1168
1169static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid) 1169static int _mv88e6xxx_port_pvid(struct dsa_switch *ds, int port, u16 *new,
1170 u16 *old)
1170{ 1171{
1172 u16 pvid;
1171 int ret; 1173 int ret;
1172 1174
1173 ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN); 1175 ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN);
1174 if (ret < 0) 1176 if (ret < 0)
1175 return ret; 1177 return ret;
1176 1178
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;
1178 1196
1179 return 0; 1197 return 0;
1180} 1198}
1181 1199
1200static 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
1182static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid) 1205static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid)
1183{ 1206{
1184 return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_DEFAULT_VLAN, 1207 return _mv88e6xxx_port_pvid(ds, port, &pvid, NULL);
1185 pvid & PORT_DEFAULT_VLAN_MASK);
1186} 1208}
1187 1209
1188static int _mv88e6xxx_vtu_wait(struct dsa_switch *ds) 1210static int _mv88e6xxx_vtu_wait(struct dsa_switch *ds)