diff options
author | David S. Miller <davem@davemloft.net> | 2017-10-18 12:24:34 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-18 12:24:34 +0100 |
commit | 1bbc728988f09e40c83585cf3322b1f6c1aa17b5 (patch) | |
tree | d73285634543e8063d66da030e34a218fc76e805 /net/dsa/dsa_priv.h | |
parent | a2084f5650624edd0805dc78260d097df4f38eb6 (diff) | |
parent | c8652c83bc84ac8db44060ced0036de7628aa5e5 (diff) | |
download | linux-1bbc728988f09e40c83585cf3322b1f6c1aa17b5.tar.gz linux-1bbc728988f09e40c83585cf3322b1f6c1aa17b5.tar.bz2 linux-1bbc728988f09e40c83585cf3322b1f6c1aa17b5.zip |
Merge branch 'dsa-master-and-slave-helpers'
Vivien Didelot says:
====================
net: dsa: master and slave helpers
This patch series adds a few helpers to DSA core for clarity and
readability but brings no functional changes.
A dsa_slave_notify helper calls the DSA notifiers when (un)registering a
slave device.
Most of the DSA slave code only needs to access the dsa_port structure,
not the dsa_slave_priv (which only contains a few PHY-specific members).
Thus a dsa_slave_to_port helper returns a dsa_port structure of a slave
device.
A dsa_slave_to_master returns the master device of a slave device.
After that the netdev member of the dsa_port structure is split into two
explicit master and slave members to avoid confusion, and a dsa_to_port
helper is added for switch drivers to get a const reference to a port.
Changes in v2:
- prefer dsa_slave_to_master instead of dsa_slave_get_master
- rename dsa_master_get_slave to dsa_master_find_slave
- pack master and slave net devices into an anonymous union
- add dsa_to_port public helper for switch drivers
- add Reviewed-by tags from Florian
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa_priv.h')
-rw-r--r-- | net/dsa/dsa_priv.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 2850077cc9cc..1e9914062d0b 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -113,8 +113,8 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], int dsa_master_ethtool_setup(struct net_device *dev); void dsa_master_ethtool_restore(struct net_device *dev); -static inline struct net_device *dsa_master_get_slave(struct net_device *dev, - int device, int port) +static inline struct net_device *dsa_master_find_slave(struct net_device *dev, + int device, int port) { struct dsa_port *cpu_dp = dev->dsa_ptr; struct dsa_switch_tree *dst = cpu_dp->dst; @@ -130,7 +130,7 @@ static inline struct net_device *dsa_master_get_slave(struct net_device *dev, if (port < 0 || port >= ds->num_ports) return NULL; - return ds->ports[port].netdev; + return ds->ports[port].slave; } /* port.c */ @@ -169,6 +169,21 @@ int dsa_slave_resume(struct net_device *slave_dev); int dsa_slave_register_notifier(void); void dsa_slave_unregister_notifier(void); +static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev) +{ + struct dsa_slave_priv *p = netdev_priv(dev); + + return p->dp; +} + +static inline struct net_device * +dsa_slave_to_master(const struct net_device *dev) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + + return dp->cpu_dp->master; +} + /* switch.c */ int dsa_switch_register_notifier(struct dsa_switch *ds); void dsa_switch_unregister_notifier(struct dsa_switch *ds); @@ -197,9 +212,4 @@ extern const struct dsa_device_ops qca_netdev_ops; /* tag_trailer.c */ extern const struct dsa_device_ops trailer_netdev_ops; -static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p) -{ - return p->dp->cpu_dp->netdev; -} - #endif |