aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2016-06-07 19:32:40 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-08 14:23:41 -0400
commit1eb59443e72c69edbb836626f9f7f7e82427eeac (patch)
tree943a2b03b3da319d2071aac18f0ddd2f9d4758ed /net/dsa
parent6e830d8f0deca91fcb84d3156dcebb20384a9e2d (diff)
net: dsa: Provide a slave MII bus if needed
Mimic what net/dsa/dsa.c does and provide a slave MII bus by default which will be created if the driver implements a phy_read method. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa2.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 921a36fd139d..4e0f3c268103 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -312,6 +312,18 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
312 if (err < 0) 312 if (err < 0)
313 return err; 313 return err;
314 314
315 if (!ds->slave_mii_bus && ds->drv->phy_read) {
316 ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
317 if (!ds->slave_mii_bus)
318 return -ENOMEM;
319
320 dsa_slave_mii_bus_init(ds);
321
322 err = mdiobus_register(ds->slave_mii_bus);
323 if (err < 0)
324 return err;
325 }
326
315 for (index = 0; index < DSA_MAX_PORTS; index++) { 327 for (index = 0; index < DSA_MAX_PORTS; index++) {
316 port = ds->ports[index].dn; 328 port = ds->ports[index].dn;
317 if (!port) 329 if (!port)
@@ -361,6 +373,9 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
361 373
362 dsa_user_port_unapply(port, index, ds); 374 dsa_user_port_unapply(port, index, ds);
363 } 375 }
376
377 if (ds->slave_mii_bus && ds->drv->phy_read)
378 mdiobus_unregister(ds->slave_mii_bus);
364} 379}
365 380
366static int dsa_dst_apply(struct dsa_switch_tree *dst) 381static int dsa_dst_apply(struct dsa_switch_tree *dst)