Introduce a DSA helper to find a dsa_switch structure by ID from a master interface, that will be useful for frames with a switch ID but no port ID.
Signed-off-by: Vivien Didelot <vivien.dide...@gmail.com> --- net/dsa/dsa_priv.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 8f1222324646..2a8ee4c6adc5 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -103,18 +103,25 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp); void dsa_master_teardown(struct net_device *dev); -static inline struct net_device *dsa_master_find_slave(struct net_device *dev, - int device, int port) +static inline struct dsa_switch *dsa_master_find_switch(struct net_device *dev, + int device) { struct dsa_port *cpu_dp = dev->dsa_ptr; struct dsa_switch_tree *dst = cpu_dp->dst; - struct dsa_switch *ds; - struct dsa_port *slave_port; if (device < 0 || device >= DSA_MAX_SWITCHES) return NULL; - ds = dst->ds[device]; + return dst->ds[device]; +} + +static inline struct net_device *dsa_master_find_slave(struct net_device *dev, + int device, int port) +{ + struct dsa_port *slave_port; + struct dsa_switch *ds; + + ds = dsa_master_find_switch(dev, device); if (!ds) return NULL; -- 2.21.0