Commit 79a62eb2 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

dsa: use prepare/commit switchdev transaction helpers

The enum is going to disappear, use the helpers instead.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f6467cf
...@@ -251,8 +251,7 @@ static int dsa_slave_port_vlan_add(struct net_device *dev, ...@@ -251,8 +251,7 @@ static int dsa_slave_port_vlan_add(struct net_device *dev,
u16 vid; u16 vid;
int err; int err;
switch (trans->ph) { if (switchdev_trans_ph_prepare(trans)) {
case SWITCHDEV_TRANS_PREPARE:
if (!ds->drv->port_vlan_add || !ds->drv->port_pvid_set) if (!ds->drv->port_vlan_add || !ds->drv->port_pvid_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -264,8 +263,7 @@ static int dsa_slave_port_vlan_add(struct net_device *dev, ...@@ -264,8 +263,7 @@ static int dsa_slave_port_vlan_add(struct net_device *dev,
vlan->vid_end); vlan->vid_end);
if (err) if (err)
return err; return err;
break; } else {
case SWITCHDEV_TRANS_COMMIT:
for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
err = ds->drv->port_vlan_add(ds, p->port, vid, err = ds->drv->port_vlan_add(ds, p->port, vid,
vlan->flags & vlan->flags &
...@@ -275,9 +273,6 @@ static int dsa_slave_port_vlan_add(struct net_device *dev, ...@@ -275,9 +273,6 @@ static int dsa_slave_port_vlan_add(struct net_device *dev,
if (err) if (err)
return err; return err;
} }
break;
default:
return -EOPNOTSUPP;
} }
return 0; return 0;
...@@ -356,9 +351,9 @@ static int dsa_slave_port_fdb_add(struct net_device *dev, ...@@ -356,9 +351,9 @@ static int dsa_slave_port_fdb_add(struct net_device *dev,
struct dsa_switch *ds = p->parent; struct dsa_switch *ds = p->parent;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
if (trans->ph == SWITCHDEV_TRANS_PREPARE) if (switchdev_trans_ph_prepare(trans))
ret = ds->drv->port_fdb_add ? 0 : -EOPNOTSUPP; ret = ds->drv->port_fdb_add ? 0 : -EOPNOTSUPP;
else if (trans->ph == SWITCHDEV_TRANS_COMMIT) else
ret = ds->drv->port_fdb_add(ds, p->port, fdb->addr, fdb->vid); ret = ds->drv->port_fdb_add(ds, p->port, fdb->addr, fdb->vid);
return ret; return ret;
...@@ -465,7 +460,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev, ...@@ -465,7 +460,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
switch (attr->id) { switch (attr->id) {
case SWITCHDEV_ATTR_PORT_STP_STATE: case SWITCHDEV_ATTR_PORT_STP_STATE:
if (trans->ph == SWITCHDEV_TRANS_COMMIT) if (switchdev_trans_ph_commit(trans))
ret = dsa_slave_stp_update(dev, attr->u.stp_state); ret = dsa_slave_stp_update(dev, attr->u.stp_state);
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment