Add two new methods into the DSA operations structure: - port_setup(), called from dsa_port_setup() after the DSA port already registered - port_teardown(), called from dsa_port_teardown() before the port is unregistered
Signed-off-by: Marek Behún <marek.be...@nic.cz> Cc: Andrew Lunn <and...@lunn.ch> Cc: Florian Fainelli <f.faine...@gmail.com> Cc: Vladimir Oltean <olte...@gmail.com> Cc: Vivien Didelot <vivien.dide...@gmail.com> --- include/net/dsa.h | 2 ++ net/dsa/dsa2.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 147b757ef8ea..848898e5d7c5 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -360,6 +360,8 @@ struct dsa_switch_ops { int (*setup)(struct dsa_switch *ds); void (*teardown)(struct dsa_switch *ds); + int (*port_setup)(struct dsa_switch *ds, int port); + void (*port_teardown)(struct dsa_switch *ds, int port); u32 (*get_phy_flags)(struct dsa_switch *ds, int port); /* diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 3abd173ebacb..c891300a6d2c 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -315,6 +315,9 @@ static int dsa_port_setup(struct dsa_port *dp) break; } + if (!err && ds->ops->port_setup) + err = ds->ops->port_setup(ds, dp->index); + if (err) devlink_port_unregister(&dp->devlink_port); @@ -323,8 +326,13 @@ static int dsa_port_setup(struct dsa_port *dp) static void dsa_port_teardown(struct dsa_port *dp) { - if (dp->type != DSA_PORT_TYPE_UNUSED) + struct dsa_switch *ds = dp->ds; + + if (dp->type != DSA_PORT_TYPE_UNUSED) { devlink_port_unregister(&dp->devlink_port); + if (ds->ops->port_teardown) + ds->ops->port_teardown(ds, dp->index); + } switch (dp->type) { case DSA_PORT_TYPE_UNUSED: -- 2.21.0