Skip to content

Commit c5d35cb

Browse files
viviendavem330
authored andcommitted
net: dsa: change state setter scope
The scope of the functions inside net/dsa/slave.c must be the slave net_device pointer. Change to state setter helper accordingly to simplify callers. Signed-off-by: Vivien Didelot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9c26542 commit c5d35cb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

net/dsa/slave.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ static inline bool dsa_port_is_bridged(struct dsa_port *dp)
7474
return !!dp->bridge_dev;
7575
}
7676

77-
static void dsa_port_set_stp_state(struct dsa_switch *ds, int port, u8 state)
77+
static void dsa_slave_set_state(struct net_device *dev, u8 state)
7878
{
79-
struct dsa_port *dp = &ds->ports[port];
79+
struct dsa_slave_priv *p = netdev_priv(dev);
80+
struct dsa_port *dp = p->dp;
81+
struct dsa_switch *ds = dp->ds;
82+
int port = dp->index;
8083

8184
if (ds->ops->port_stp_state_set)
8285
ds->ops->port_stp_state_set(ds, port, state);
@@ -133,7 +136,7 @@ static int dsa_slave_open(struct net_device *dev)
133136
goto clear_promisc;
134137
}
135138

136-
dsa_port_set_stp_state(ds, p->dp->index, stp_state);
139+
dsa_slave_set_state(dev, stp_state);
137140

138141
if (p->phy)
139142
phy_start(p->phy);
@@ -175,7 +178,7 @@ static int dsa_slave_close(struct net_device *dev)
175178
if (ds->ops->port_disable)
176179
ds->ops->port_disable(ds, p->dp->index, p->phy);
177180

178-
dsa_port_set_stp_state(ds, p->dp->index, BR_STATE_DISABLED);
181+
dsa_slave_set_state(dev, BR_STATE_DISABLED);
179182

180183
return 0;
181184
}
@@ -382,7 +385,7 @@ static int dsa_slave_stp_state_set(struct net_device *dev,
382385
if (switchdev_trans_ph_prepare(trans))
383386
return ds->ops->port_stp_state_set ? 0 : -EOPNOTSUPP;
384387

385-
dsa_port_set_stp_state(ds, p->dp->index, attr->u.stp_state);
388+
dsa_slave_set_state(dev, attr->u.stp_state);
386389

387390
return 0;
388391
}
@@ -596,7 +599,7 @@ static void dsa_slave_bridge_port_leave(struct net_device *dev,
596599
/* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
597600
* so allow it to be in BR_STATE_FORWARDING to be kept functional
598601
*/
599-
dsa_port_set_stp_state(ds, p->dp->index, BR_STATE_FORWARDING);
602+
dsa_slave_set_state(dev, BR_STATE_FORWARDING);
600603
}
601604

602605
static int dsa_slave_port_attr_get(struct net_device *dev,

0 commit comments

Comments
 (0)