Commit 5c5d6b34 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller
Browse files

net: dsa: qca8k: consolidate calls to a single devm_of_mdiobus_register()



__of_mdiobus_register() already calls __mdiobus_register() if the
OF node provided as argument is NULL. We can take advantage of that
and simplify the 2 code path, calling devm_of_mdiobus_register() only
once for both cases.

Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Reviewed-by: default avatarLuiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 525366b8
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -967,25 +967,23 @@ qca8k_mdio_register(struct qca8k_priv *priv)
		 ds->dst->index, ds->index);
	bus->parent = ds->dev;

	/* Check if the devicetree declare the port:phy mapping */
	if (mdio) {
		/* Check if the device tree declares the port:phy mapping */
		bus->name = "qca8k user mii";
		bus->read = qca8k_internal_mdio_read;
		bus->write = qca8k_internal_mdio_write;
		err = devm_of_mdiobus_register(priv->dev, bus, mdio);
		goto out_put_node;
	}

	/* If a mapping can't be found the legacy mapping is used,
	 * using the qca8k_port_to_phy function
	} else {
		/* If a mapping can't be found, the legacy mapping is used,
		 * using qca8k_port_to_phy()
		 */
		ds->user_mii_bus = bus;
		bus->phy_mask = ~ds->phys_mii_mask;
		bus->name = "qca8k-legacy user mii";
		bus->read = qca8k_legacy_mdio_read;
		bus->write = qca8k_legacy_mdio_write;
	}

	err = devm_mdiobus_register(priv->dev, bus);
	err = devm_of_mdiobus_register(priv->dev, bus, mdio);

out_put_node:
	of_node_put(mdio);