@@ -1359,6 +1359,23 @@ int dsa_register_switch(struct dsa_switch *ds);
void dsa_switch_shutdown(struct dsa_switch *ds);
struct dsa_switch *dsa_switch_find(int tree_index, int sw_index);
void dsa_flush_workqueue(void);
+
+struct dsa_port *dsa_user_to_port(const struct net_device *dev);
+
+static inline struct dsa_switch *dsa_user_to_ds(const struct net_device *ndev)
+{
+ struct dsa_port *dp = dsa_user_to_port(ndev);
+
+ return dp->ds;
+}
+
+static inline unsigned int dsa_user_to_index(const struct net_device *ndev)
+{
+ struct dsa_port *dp = dsa_user_to_port(ndev);
+
+ return dp->index;
+}
+
#ifdef CONFIG_PM_SLEEP
int dsa_switch_suspend(struct dsa_switch *ds);
int dsa_switch_resume(struct dsa_switch *ds);
@@ -3699,3 +3699,11 @@ void dsa_user_unregister_notifier(void)
if (err)
pr_err("DSA: failed to unregister user notifier (%d)\n", err);
}
+
+struct dsa_port *dsa_user_to_port(const struct net_device *dev)
+{
+ struct dsa_user_priv *p = netdev_priv(dev);
+
+ return p->dp;
+}
+EXPORT_SYMBOL_GPL(dsa_user_to_port);
@@ -51,13 +51,6 @@ int dsa_user_change_conduit(struct net_device *dev, struct net_device *conduit,
int dsa_user_manage_vlan_filtering(struct net_device *dev,
bool vlan_filtering);
-static inline struct dsa_port *dsa_user_to_port(const struct net_device *dev)
-{
- struct dsa_user_priv *p = netdev_priv(dev);
-
- return p->dp;
-}
-
static inline struct net_device *
dsa_user_to_conduit(const struct net_device *dev)
{
The LED helpers make use of a struct netdev. Add helpers a DSA driver can use to convert a netdev to a struct dsa_switch and the port index. To do this, dsa_user_to_port() has to be made available out side of net/dev, to convert the inline function in net/dsa/user.h into a normal function, and export it. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- include/net/dsa.h | 17 +++++++++++++++++ net/dsa/user.c | 8 ++++++++ net/dsa/user.h | 7 ------- 3 files changed, 25 insertions(+), 7 deletions(-)