net: dsa: Remove master_netdev and use dst->cpu_dp->netdev

In preparation for supporting multiple CPU ports, remove
dst->master_netdev and ds->master_netdev and replace them with only one
instance of the common object we have for a port: struct
dsa_port::netdev. ds->master_netdev is currently write only and would be
helpful in the case where we have two switches, both with CPU ports, and
also connected within each other, which the multi-CPU port patch series
would address.

While at it, introduce a helper function used in net/dsa/slave.c to
immediately get a reference on the master network device called
dsa_master_netdev().

Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Florian Fainelli
2017-06-13 13:27:19 -07:00
committed by David S. Miller
parent 38b6ec5008
commit 6d3c8c0dd8
8 changed files with 40 additions and 48 deletions

View File

@@ -118,10 +118,7 @@ int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp)
struct net_device *master;
struct ethtool_ops *cpu_ops;
master = ds->dst->master_netdev;
if (ds->master_netdev)
master = ds->master_netdev;
master = ds->dst->cpu_dp->netdev;
cpu_ops = devm_kzalloc(ds->dev, sizeof(*cpu_ops), GFP_KERNEL);
if (!cpu_ops)
return -ENOMEM;
@@ -142,9 +139,7 @@ void dsa_cpu_port_ethtool_restore(struct dsa_port *cpu_dp)
struct dsa_switch *ds = cpu_dp->ds;
struct net_device *master;
master = ds->dst->master_netdev;
if (ds->master_netdev)
master = ds->master_netdev;
master = ds->dst->cpu_dp->netdev;
master->ethtool_ops = ds->dst->master_orig_ethtool_ops;
}