Commit e755e49e authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

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: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 39a7f2a4
...@@ -340,8 +340,9 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -340,8 +340,9 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
if (ret < 0) if (ret < 0)
goto out; goto out;
if (!ds->slave_mii_bus && drv->phy_read) {
ds->slave_mii_bus = devm_mdiobus_alloc(parent); ds->slave_mii_bus = devm_mdiobus_alloc(parent);
if (ds->slave_mii_bus == NULL) { if (!ds->slave_mii_bus) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
...@@ -350,7 +351,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -350,7 +351,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
ret = mdiobus_register(ds->slave_mii_bus); ret = mdiobus_register(ds->slave_mii_bus);
if (ret < 0) if (ret < 0)
goto out; goto out;
}
/* /*
* Create network devices for physical switch ports. * Create network devices for physical switch ports.
...@@ -493,6 +494,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds) ...@@ -493,6 +494,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
dsa_cpu_dsa_destroy(ds->ports[port].dn); dsa_cpu_dsa_destroy(ds->ports[port].dn);
} }
if (ds->slave_mii_bus && ds->drv->phy_read)
mdiobus_unregister(ds->slave_mii_bus); mdiobus_unregister(ds->slave_mii_bus);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment