Thread (19 messages) flat view 19 messages, 3 authors, 2016-06-07

Re: [PATCH net-next v2 2/5] net: dsa: Initialize ds->enabled_port_mask and ds->phys_mii_mask

From: Andrew Lunn <andrew@lunn.ch>
Date: 2016-06-07 13:05:49

On Tue, Jun 07, 2016 at 02:22:12AM +0200, Andrew Lunn wrote:
quoted
@@ -304,6 +312,18 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 	if (err < 0)
 		return err;
 
+	if (!ds->slave_mii_bus && ds->drv->phy_read) {
+		ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
+		if (!ds->slave_mii_bus)
+			return err;
+
+		dsa_slave_mii_bus_init(ds);
+
+		err = mdiobus_register(ds->slave_mii_bus);
+		if (err < 0)
+			return err;
+	}
+
 	for (index = 0; index < DSA_MAX_PORTS; index++) {
 		port = ds->ports[index].dn;
 		if (!port)
Hi Florian
...
 
It is also missing the unregister in dsa_ds_unapply().
Looking at this again...

You use devm_mdiobus_alloc(), so the memory for the bus will get freed
eventually. However, it won't get unregistered before it is freed.  So
an explicit unregister is needed. Doing that in dsa_ds_unapply() makes
sense, so we have a clear life cycle for this mdio bus.

       Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help