net: dsa: Add helper to convert from devlink to ds

Given a devlink instance, return the dsa switch it is associated to.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Andrew Lunn
2020-09-18 18:17:45 -07:00
committed by David S. Miller
parent d4602a9f47
commit ccc3e6b019
2 changed files with 9 additions and 10 deletions
+7
View File
@@ -664,6 +664,13 @@ struct dsa_devlink_priv {
struct dsa_switch *ds;
};
static inline struct dsa_switch *dsa_devlink_to_ds(struct devlink *dl)
{
struct dsa_devlink_priv *dl_priv = devlink_priv(dl);
return dl_priv->ds;
}
struct dsa_switch_driver {
struct list_head list;
const struct dsa_switch_ops *ops;