aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/tag_8021q.c
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2021-07-19 20:14:50 +0300
committerDavid S. Miller <davem@davemloft.net>2021-07-20 06:36:42 -0700
commit328621f6131f667c5c328bb72d45442fd76efb81 (patch)
tree120defbf9450e0cf388ecdeae9b9bc37087ae47f /net/dsa/tag_8021q.c
parentnet: dsa: make tag_8021q operations part of the core (diff)
downloadlinux-dev-328621f6131f667c5c328bb72d45442fd76efb81.tar.xz
linux-dev-328621f6131f667c5c328bb72d45442fd76efb81.zip
net: dsa: tag_8021q: absorb dsa_8021q_setup into dsa_tag_8021q_{,un}register
Right now, setting up tag_8021q is a 2-step operation for a driver, first the context structure needs to be created, then the VLANs need to be installed on the ports. A similar thing is true for teardown. Merge the 2 steps into the register/unregister methods, to be as transparent as possible for the driver as to what tag_8021q does behind the scenes. This also gets rid of the funny "bool setup == true means setup, == false means teardown" API that tag_8021q used to expose. Note that dsa_tag_8021q_register() must be called at least in the .setup() driver method and never earlier (like in the driver probe function). This is because the DSA switch tree is not initialized at probe time, and the cross-chip notifiers will not work. For symmetry with .setup(), the unregister method should be put in .teardown(). Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/tag_8021q.c')
-rw-r--r--net/dsa/tag_8021q.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c
index 4a11c5004783..9785c8497039 100644
--- a/net/dsa/tag_8021q.c
+++ b/net/dsa/tag_8021q.c
@@ -257,7 +257,7 @@ static int dsa_8021q_setup_port(struct dsa_switch *ds, int port, bool enabled)
return err;
}
-int dsa_8021q_setup(struct dsa_switch *ds, bool enabled)
+static int dsa_8021q_setup(struct dsa_switch *ds, bool enabled)
{
int err, port;
@@ -275,7 +275,6 @@ int dsa_8021q_setup(struct dsa_switch *ds, bool enabled)
return 0;
}
-EXPORT_SYMBOL_GPL(dsa_8021q_setup);
static int dsa_8021q_crosschip_link_apply(struct dsa_switch *ds, int port,
struct dsa_switch *other_ds,
@@ -427,7 +426,7 @@ int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto)
ds->tag_8021q_ctx = ctx;
- return 0;
+ return dsa_8021q_setup(ds, true);
}
EXPORT_SYMBOL_GPL(dsa_tag_8021q_register);
@@ -435,6 +434,12 @@ void dsa_tag_8021q_unregister(struct dsa_switch *ds)
{
struct dsa_8021q_context *ctx = ds->tag_8021q_ctx;
struct dsa_8021q_crosschip_link *c, *n;
+ int err;
+
+ err = dsa_8021q_setup(ds, false);
+ if (err)
+ dev_err(ds->dev, "failed to tear down tag_8021q VLANs: %pe\n",
+ ERR_PTR(err));
list_for_each_entry_safe(c, n, &ctx->crosschip_links, list) {
list_del(&c->list);