Skip to content

Commit

Permalink
net: dsa: qca8k: consolidate calls to a single devm_of_mdiobus_regist…
Browse files Browse the repository at this point in the history
…er()

__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: Vladimir Oltean <[email protected]>
Reviewed-by: Alvin Šipraga <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Reviewed-by: Christian Marangi <[email protected]>
Reviewed-by: Luiz Angelo Daros de Luca <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vladimiroltean authored and davem330 committed Jan 5, 2024
1 parent 525366b commit 5c5d6b3
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions drivers/net/dsa/qca/qca8k-8xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
} 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;
}

/* If a mapping can't be found the legacy mapping is used,
* using the qca8k_port_to_phy function
*/
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);
Expand Down

0 comments on commit 5c5d6b3

Please sign in to comment.