diff options
Diffstat (limited to 'drivers/net/dsa/lantiq_gswip.c')
-rw-r--r-- | drivers/net/dsa/lantiq_gswip.c | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index 9c185c9f09..de48b19404 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -505,27 +505,34 @@ static int gswip_mdio_rd(struct mii_bus *bus, int addr, int reg) return gswip_mdio_r(priv, GSWIP_MDIO_READ); } -static int gswip_mdio(struct gswip_priv *priv, struct device_node *mdio_np) +static int gswip_mdio(struct gswip_priv *priv) { - struct dsa_switch *ds = priv->ds; - int err; + struct device_node *mdio_np, *switch_np = priv->dev->of_node; + struct device *dev = priv->dev; + struct mii_bus *bus; + int err = 0; - ds->user_mii_bus = mdiobus_alloc(); - if (!ds->user_mii_bus) - return -ENOMEM; + mdio_np = of_get_compatible_child(switch_np, "lantiq,xrx200-mdio"); + if (!of_device_is_available(mdio_np)) + goto out_put_node; - ds->user_mii_bus->priv = priv; - ds->user_mii_bus->read = gswip_mdio_rd; - ds->user_mii_bus->write = gswip_mdio_wr; - ds->user_mii_bus->name = "lantiq,xrx200-mdio"; - snprintf(ds->user_mii_bus->id, MII_BUS_ID_SIZE, "%s-mii", - dev_name(priv->dev)); - ds->user_mii_bus->parent = priv->dev; - ds->user_mii_bus->phy_mask = ~ds->phys_mii_mask; + bus = devm_mdiobus_alloc(dev); + if (!bus) { + err = -ENOMEM; + goto out_put_node; + } - err = of_mdiobus_register(ds->user_mii_bus, mdio_np); - if (err) - mdiobus_free(ds->user_mii_bus); + bus->priv = priv; + bus->read = gswip_mdio_rd; + bus->write = gswip_mdio_wr; + bus->name = "lantiq,xrx200-mdio"; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(priv->dev)); + bus->parent = priv->dev; + + err = devm_of_mdiobus_register(dev, bus, mdio_np); + +out_put_node: + of_node_put(mdio_np); return err; } @@ -1759,7 +1766,7 @@ static void gswip_get_strings(struct dsa_switch *ds, int port, u32 stringset, return; for (i = 0; i < ARRAY_SIZE(gswip_rmon_cnt); i++) - ethtool_sprintf(&data, "%s", gswip_rmon_cnt[i].name); + ethtool_puts(&data, gswip_rmon_cnt[i].name); } static u32 gswip_bcm_ram_entry_read(struct gswip_priv *priv, u32 table, @@ -2094,9 +2101,9 @@ remove_gphy: static int gswip_probe(struct platform_device *pdev) { - struct gswip_priv *priv; - struct device_node *np, *mdio_np, *gphy_fw_np; + struct device_node *np, *gphy_fw_np; struct device *dev = &pdev->dev; + struct gswip_priv *priv; int err; int i; u32 version; @@ -2163,19 +2170,16 @@ static int gswip_probe(struct platform_device *pdev) } /* bring up the mdio bus */ - mdio_np = of_get_compatible_child(dev->of_node, "lantiq,xrx200-mdio"); - if (mdio_np) { - err = gswip_mdio(priv, mdio_np); - if (err) { - dev_err(dev, "mdio probe failed\n"); - goto put_mdio_node; - } + err = gswip_mdio(priv); + if (err) { + dev_err(dev, "mdio probe failed\n"); + goto gphy_fw_remove; } err = dsa_register_switch(priv->ds); if (err) { dev_err(dev, "dsa switch register failed: %i\n", err); - goto mdio_bus; + goto gphy_fw_remove; } if (!dsa_is_cpu_port(priv->ds, priv->hw_info->cpu_port)) { dev_err(dev, "wrong CPU port defined, HW only supports port: %i", @@ -2194,13 +2198,7 @@ static int gswip_probe(struct platform_device *pdev) disable_switch: gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB); dsa_unregister_switch(priv->ds); -mdio_bus: - if (mdio_np) { - mdiobus_unregister(priv->ds->user_mii_bus); - mdiobus_free(priv->ds->user_mii_bus); - } -put_mdio_node: - of_node_put(mdio_np); +gphy_fw_remove: for (i = 0; i < priv->num_gphy_fw; i++) gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]); return err; @@ -2219,12 +2217,6 @@ static void gswip_remove(struct platform_device *pdev) dsa_unregister_switch(priv->ds); - if (priv->ds->user_mii_bus) { - mdiobus_unregister(priv->ds->user_mii_bus); - of_node_put(priv->ds->user_mii_bus->dev.of_node); - mdiobus_free(priv->ds->user_mii_bus); - } - for (i = 0; i < priv->num_gphy_fw; i++) gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]); } |