Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: qca8k: skip MDIO bus creation if its OF node has status = "disabled"

Currently the driver calls the non-OF devm_mdiobus_register() rather
than devm_of_mdiobus_register() for this case, but it seems to rather
be a confusing coincidence, and not a real use case that needs to be
supported.

If the device tree says status = "disabled" for the MDIO bus, we
shouldn't need an MDIO bus at all. Instead, just exit as early as
possible and do not call any MDIO API.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
e66bf63a 68e1010c

+5 -3
+5 -3
drivers/net/dsa/qca/qca8k-8xxx.c
··· 949 949 struct dsa_switch *ds = priv->ds; 950 950 struct device_node *mdio; 951 951 struct mii_bus *bus; 952 - int err; 952 + int err = 0; 953 953 954 954 mdio = of_get_child_by_name(priv->dev->of_node, "mdio"); 955 + if (mdio && !of_device_is_available(mdio)) 956 + goto out; 955 957 956 958 bus = devm_mdiobus_alloc(ds->dev); 957 959 if (!bus) { ··· 969 967 ds->user_mii_bus = bus; 970 968 971 969 /* Check if the devicetree declare the port:phy mapping */ 972 - if (of_device_is_available(mdio)) { 970 + if (mdio) { 973 971 bus->name = "qca8k user mii"; 974 972 bus->read = qca8k_internal_mdio_read; 975 973 bus->write = qca8k_internal_mdio_write; ··· 988 986 989 987 out_put_node: 990 988 of_node_put(mdio); 991 - 989 + out: 992 990 return err; 993 991 } 994 992