summaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@gmail.com>2019-10-21 22:51:30 +0200
committerJakub Kicinski <jakub.kicinski@netronome.com>2019-10-22 21:37:07 +0200
commit7e99e34701728d54ccd0466eccf377a42b9db215 (patch)
tree9047ed67e960bddc994b2bf7a4ecbb8fa0c8ca16 /net/dsa
parentnet: dsa: allocate ports on touch (diff)
downloadlinux-7e99e34701728d54ccd0466eccf377a42b9db215.tar.xz
linux-7e99e34701728d54ccd0466eccf377a42b9db215.zip
net: dsa: remove dsa_switch_alloc helper
Now that ports are dynamically listed in the fabric, there is no need to provide a special helper to allocate the dsa_switch structure. This will give more flexibility to drivers to embed this structure as they wish in their private structure. Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa2.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 83cba4623698..1e3ac9b56c89 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -846,6 +846,12 @@ static int dsa_switch_probe(struct dsa_switch *ds)
struct device_node *np = ds->dev->of_node;
int err;
+ if (!ds->dev)
+ return -ENODEV;
+
+ if (!ds->num_ports)
+ return -EINVAL;
+
if (np)
err = dsa_switch_parse_of(ds, np);
else if (pdata)
@@ -859,21 +865,6 @@ static int dsa_switch_probe(struct dsa_switch *ds)
return dsa_switch_add(ds);
}
-struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n)
-{
- struct dsa_switch *ds;
-
- ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
- if (!ds)
- return NULL;
-
- ds->dev = dev;
- ds->num_ports = n;
-
- return ds;
-}
-EXPORT_SYMBOL_GPL(dsa_switch_alloc);
-
int dsa_register_switch(struct dsa_switch *ds)
{
int err;