summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2021-07-19 20:14:46 +0300
committerDavid S. Miller <davem@davemloft.net>2021-07-20 06:36:42 -0700
commitcedf467064b6b8764fdb2ee6b9e3d18bc81a9d8f (patch)
tree4459c6269caff331f47edcc5b788327ba5d5d536 /drivers
parent8afbea187d31e4e9beb83b7a316d16b7879c2799 (diff)
downloadlinux-stable-cedf467064b6b8764fdb2ee6b9e3d18bc81a9d8f.tar.gz
linux-stable-cedf467064b6b8764fdb2ee6b9e3d18bc81a9d8f.tar.bz2
linux-stable-cedf467064b6b8764fdb2ee6b9e3d18bc81a9d8f.zip
net: dsa: tag_8021q: create dsa_tag_8021q_{register,unregister} helpers
In preparation of moving tag_8021q to core DSA, move all initialization and teardown related to tag_8021q which is currently done by drivers in 2 functions called "register" and "unregister". These will gather more functionality in future patches, which will better justify the chosen naming scheme. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/dsa/ocelot/felix.c12
-rw-r--r--drivers/net/dsa/sja1105/sja1105_main.c18
2 files changed, 13 insertions, 17 deletions
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index a2a15919b960..b52cc381cdc1 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -425,15 +425,11 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu)
ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_MC);
ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_BC);
- felix->dsa_8021q_ctx = kzalloc(sizeof(*felix->dsa_8021q_ctx),
- GFP_KERNEL);
+ felix->dsa_8021q_ctx = dsa_tag_8021q_register(ds, &felix_tag_8021q_ops,
+ htons(ETH_P_8021AD));
if (!felix->dsa_8021q_ctx)
return -ENOMEM;
- felix->dsa_8021q_ctx->ops = &felix_tag_8021q_ops;
- felix->dsa_8021q_ctx->proto = htons(ETH_P_8021AD);
- felix->dsa_8021q_ctx->ds = ds;
-
err = dsa_8021q_setup(felix->dsa_8021q_ctx, true);
if (err)
goto out_free_dsa_8021_ctx;
@@ -447,7 +443,7 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu)
out_teardown_dsa_8021q:
dsa_8021q_setup(felix->dsa_8021q_ctx, false);
out_free_dsa_8021_ctx:
- kfree(felix->dsa_8021q_ctx);
+ dsa_tag_8021q_unregister(felix->dsa_8021q_ctx);
return err;
}
@@ -466,7 +462,7 @@ static void felix_teardown_tag_8021q(struct dsa_switch *ds, int cpu)
if (err)
dev_err(ds->dev, "dsa_8021q_setup returned %d", err);
- kfree(felix->dsa_8021q_ctx);
+ dsa_tag_8021q_unregister(felix->dsa_8021q_ctx);
for (port = 0; port < ds->num_ports; port++) {
if (dsa_is_unused_port(ds, port))
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 4514ac468cc8..689f46797d1c 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -3306,16 +3306,11 @@ static int sja1105_probe(struct spi_device *spi)
mutex_init(&priv->ptp_data.lock);
mutex_init(&priv->mgmt_lock);
- priv->dsa_8021q_ctx = devm_kzalloc(dev, sizeof(*priv->dsa_8021q_ctx),
- GFP_KERNEL);
+ priv->dsa_8021q_ctx = dsa_tag_8021q_register(ds, &sja1105_dsa_8021q_ops,
+ htons(ETH_P_8021Q));
if (!priv->dsa_8021q_ctx)
return -ENOMEM;
- priv->dsa_8021q_ctx->ops = &sja1105_dsa_8021q_ops;
- priv->dsa_8021q_ctx->proto = htons(ETH_P_8021Q);
- priv->dsa_8021q_ctx->ds = ds;
-
- INIT_LIST_HEAD(&priv->dsa_8021q_ctx->crosschip_links);
INIT_LIST_HEAD(&priv->bridge_vlans);
INIT_LIST_HEAD(&priv->dsa_8021q_vlans);
@@ -3324,7 +3319,7 @@ static int sja1105_probe(struct spi_device *spi)
rc = dsa_register_switch(priv->ds);
if (rc)
- return rc;
+ goto out_tag_8021q_unregister;
if (IS_ENABLED(CONFIG_NET_SCH_CBS)) {
priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers,
@@ -3377,6 +3372,8 @@ out_destroy_workers:
out_unregister_switch:
dsa_unregister_switch(ds);
+out_tag_8021q_unregister:
+ dsa_tag_8021q_unregister(priv->dsa_8021q_ctx);
return rc;
}
@@ -3384,8 +3381,11 @@ out_unregister_switch:
static int sja1105_remove(struct spi_device *spi)
{
struct sja1105_private *priv = spi_get_drvdata(spi);
+ struct dsa_switch *ds = priv->ds;
+
+ dsa_unregister_switch(ds);
+ dsa_tag_8021q_unregister(priv->dsa_8021q_ctx);
- dsa_unregister_switch(priv->ds);
return 0;
}