aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-06-04 15:17:04 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-04 17:29:54 -0400
commite755e49eb3ea925834006c294e989df52f592580 (patch)
tree22a130b4708421378138307d97c5ccfd3fe294ff /net/dsa
parent39a7f2a4eb496c0c68cc93fcb403190b48605168 (diff)
net: dsa: Make mdio bus optional
The switch may want to instantiate its own MDIO bus. Only do it centrally if the switch has not already created one, and the read op is implemented. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-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/dsa.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 221ebde4318d..6c314f300424 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -340,17 +340,18 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
340 if (ret < 0) 340 if (ret < 0)
341 goto out; 341 goto out;
342 342
343 ds->slave_mii_bus = devm_mdiobus_alloc(parent); 343 if (!ds->slave_mii_bus && drv->phy_read) {
344 if (ds->slave_mii_bus == NULL) { 344 ds->slave_mii_bus = devm_mdiobus_alloc(parent);
345 ret = -ENOMEM; 345 if (!ds->slave_mii_bus) {
346 goto out; 346 ret = -ENOMEM;
347 } 347 goto out;
348 dsa_slave_mii_bus_init(ds); 348 }
349 349 dsa_slave_mii_bus_init(ds);
350 ret = mdiobus_register(ds->slave_mii_bus);
351 if (ret < 0)
352 goto out;
353 350
351 ret = mdiobus_register(ds->slave_mii_bus);
352 if (ret < 0)
353 goto out;
354 }
354 355
355 /* 356 /*
356 * Create network devices for physical switch ports. 357 * Create network devices for physical switch ports.
@@ -493,7 +494,8 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
493 dsa_cpu_dsa_destroy(ds->ports[port].dn); 494 dsa_cpu_dsa_destroy(ds->ports[port].dn);
494 } 495 }
495 496
496 mdiobus_unregister(ds->slave_mii_bus); 497 if (ds->slave_mii_bus && ds->drv->phy_read)
498 mdiobus_unregister(ds->slave_mii_bus);
497} 499}
498 500
499#ifdef CONFIG_PM_SLEEP 501#ifdef CONFIG_PM_SLEEP