@@ -382,7 +382,6 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
struct dsa_chip_data *pd = dst->pd->chip + index;
struct dsa_switch_driver *drv;
struct dsa_switch *ds;
- int ret;
char *name;
/*
@@ -412,10 +411,6 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
ds->tag_protocol = drv->tag_protocol;
ds->master_dev = host_dev;
- ret = dsa_switch_setup_one(ds, parent);
- if (ret)
- return ERR_PTR(ret);
-
return ds;
}
@@ -827,22 +822,28 @@ static inline void dsa_of_remove(struct device *dev,
static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
struct device *parent)
{
- int i;
+ int i, ret;
unsigned configured = 0;
+ struct dsa_switch *ds;
struct dsa_platform_data *pd = dst->pd;
dst->cpu_switch = -1;
dst->cpu_port = -1;
for (i = 0; i < pd->nr_chips; i++) {
- struct dsa_switch *ds;
-
ds = dsa_switch_setup(dst, i, parent, pd->chip[i].host_dev);
if (IS_ERR(ds)) {
netdev_err(dev, "[%d]: couldn't create dsa switch instance (error %ld)\n",
i, PTR_ERR(ds));
continue;
}
+ }
+
+ for (i = 0; i < pd->nr_chips; i++) {
+ ds = dst->ds[i];
+ ret = dsa_switch_setup_one(ds, parent);
+ if (ret)
+ return ret;
dst->ds[i] = ds;
Some switches register themselves with DSA, which others are probed by DSA itself. Move the setup call to after all switches have been successfully probed. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- net/dsa/dsa.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)