drivers: net: Remove device_node checks with of_mdiobus_register()
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 15 May 2018 23:56:19 +0000 (16:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 May 2018 18:20:36 +0000 (14:20 -0400)
A number of drivers have the following pattern:

if (np)
of_mdiobus_register()
else
mdiobus_register()

which the implementation of of_mdiobus_register() now takes care of.
Remove that pattern in drivers that strictly adhere to it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Reviewed-by: Antoine Tenart <antoine.tenart@bootlin.com>
Reviewed-by: Jose Abreu <joabreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/ethernet/cadence/macb_main.c
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/marvell/mvmdio.c
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
drivers/net/ethernet/ti/davinci_mdio.c
drivers/net/phy/mdio-gpio.c
drivers/net/phy/mdio-mscc-miim.c
drivers/net/usb/lan78xx.c

index ac621f44237a97d852f6383d69031d35f7eaf124..02e8982519cebcfad46f21dbc6c53d605e6b6f8a 100644 (file)
@@ -450,12 +450,8 @@ static int bcm_sf2_mdio_register(struct dsa_switch *ds)
        priv->slave_mii_bus->parent = ds->dev->parent;
        priv->slave_mii_bus->phy_mask = ~priv->indir_phy_mask;
 
-       if (dn)
-               err = of_mdiobus_register(priv->slave_mii_bus, dn);
-       else
-               err = mdiobus_register(priv->slave_mii_bus);
-
-       if (err)
+       err = of_mdiobus_register(priv->slave_mii_bus, dn);
+       if (err && dn)
                of_node_put(dn);
 
        return err;
index b23c11d9f4b20d400f77140142607ce42599011f..2bb3f03ee1cb2e8ff9b38f98375de36beb8aa0f5 100644 (file)
@@ -2454,10 +2454,7 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
                        return err;
        }
 
-       if (np)
-               err = of_mdiobus_register(bus, np);
-       else
-               err = mdiobus_register(bus);
+       err = of_mdiobus_register(bus, np);
        if (err) {
                dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
                mv88e6xxx_g2_irq_mdio_free(chip, bus);
index b4c9268100bbc7ffd1b294dcfa2adc1902768ec5..3e93df5d4e3b2573f88cc427e7eefc6d1930e3ff 100644 (file)
@@ -591,16 +591,10 @@ static int macb_mii_init(struct macb *bp)
        dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
 
        np = bp->pdev->dev.of_node;
+       if (pdata)
+               bp->mii_bus->phy_mask = pdata->phy_mask;
 
-       if (np) {
-               err = of_mdiobus_register(bp->mii_bus, np);
-       } else {
-               if (pdata)
-                       bp->mii_bus->phy_mask = pdata->phy_mask;
-
-               err = mdiobus_register(bp->mii_bus);
-       }
-
+       err = of_mdiobus_register(bp->mii_bus, np);
        if (err)
                goto err_out_free_mdiobus;
 
index d4604bc8eb5b04742534100c4c285065bda2021e..f3e43db0d6cbf09df3a5f41e0a9eb0765b69595a 100644 (file)
@@ -2052,13 +2052,9 @@ static int fec_enet_mii_init(struct platform_device *pdev)
        fep->mii_bus->parent = &pdev->dev;
 
        node = of_get_child_by_name(pdev->dev.of_node, "mdio");
-       if (node) {
-               err = of_mdiobus_register(fep->mii_bus, node);
+       err = of_mdiobus_register(fep->mii_bus, node);
+       if (node)
                of_node_put(node);
-       } else {
-               err = mdiobus_register(fep->mii_bus);
-       }
-
        if (err)
                goto err_out_free_mdiobus;
 
index 0495487f7b42e7e80d416a2212fad2d8ca786f71..c5dac6bd2be4d31b988df0f572deedff15ce18fc 100644 (file)
@@ -348,10 +348,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
                goto out_mdio;
        }
 
-       if (pdev->dev.of_node)
-               ret = of_mdiobus_register(bus, pdev->dev.of_node);
-       else
-               ret = mdiobus_register(bus);
+       ret = of_mdiobus_register(bus, pdev->dev.of_node);
        if (ret < 0) {
                dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret);
                goto out_mdio;
index 5970d9e5ddf1516f3b5d8b95d0298e0941758a32..8dd41e08a6c632ffbf94930e820646eda370701f 100644 (file)
@@ -3025,15 +3025,10 @@ static int sh_mdio_init(struct sh_eth_private *mdp,
                 pdev->name, pdev->id);
 
        /* register MDIO bus */
-       if (dev->of_node) {
-               ret = of_mdiobus_register(mdp->mii_bus, dev->of_node);
-       } else {
-               if (pd->phy_irq > 0)
-                       mdp->mii_bus->irq[pd->phy] = pd->phy_irq;
-
-               ret = mdiobus_register(mdp->mii_bus);
-       }
+       if (pd->phy_irq > 0)
+               mdp->mii_bus->irq[pd->phy] = pd->phy_irq;
 
+       ret = of_mdiobus_register(mdp->mii_bus, dev->of_node);
        if (ret)
                goto out_free_bus;
 
index f5f37bfa1d588a639c311b75accad5e6033bca86..5df1a608e566fc26bcdac774b6cb04446d9fbf34 100644 (file)
@@ -233,10 +233,7 @@ int stmmac_mdio_register(struct net_device *ndev)
        new_bus->phy_mask = mdio_bus_data->phy_mask;
        new_bus->parent = priv->device;
 
-       if (mdio_node)
-               err = of_mdiobus_register(new_bus, mdio_node);
-       else
-               err = mdiobus_register(new_bus);
+       err = of_mdiobus_register(new_bus, mdio_node);
        if (err != 0) {
                dev_err(dev, "Cannot register the MDIO bus\n");
                goto bus_register_fail;
index 98a1c97fb95e8a4964c188db7aa53dba77cf37a3..8ac72831af050c15e2434f93711e81e8dd7e5cde 100644 (file)
@@ -429,12 +429,10 @@ static int davinci_mdio_probe(struct platform_device *pdev)
         * defined to support backward compatibility with DTs which assume that
         * Davinci MDIO will always scan the bus for PHYs detection.
         */
-       if (dev->of_node && of_get_child_count(dev->of_node)) {
+       if (dev->of_node && of_get_child_count(dev->of_node))
                data->skip_scan = true;
-               ret = of_mdiobus_register(data->bus, dev->of_node);
-       } else {
-               ret = mdiobus_register(data->bus);
-       }
+
+       ret = of_mdiobus_register(data->bus, dev->of_node);
        if (ret)
                goto bail_out;
 
index b501221819e12e32a841d46f369d50744d42415a..4e4c8daf44c308285201ecc051bc4e535e03036e 100644 (file)
@@ -179,11 +179,7 @@ static int mdio_gpio_probe(struct platform_device *pdev)
        if (!new_bus)
                return -ENODEV;
 
-       if (pdev->dev.of_node)
-               ret = of_mdiobus_register(new_bus, pdev->dev.of_node);
-       else
-               ret = mdiobus_register(new_bus);
-
+       ret = of_mdiobus_register(new_bus, pdev->dev.of_node);
        if (ret)
                mdio_gpio_bus_deinit(&pdev->dev);
 
index 8c689ccfdbca088d5722eb641205aadefca358b3..badbc99bedd3f69b35e42d23c17a4fbed2d3afa9 100644 (file)
@@ -151,11 +151,7 @@ static int mscc_miim_probe(struct platform_device *pdev)
                }
        }
 
-       if (pdev->dev.of_node)
-               ret = of_mdiobus_register(bus, pdev->dev.of_node);
-       else
-               ret = mdiobus_register(bus);
-
+       ret = of_mdiobus_register(bus, pdev->dev.of_node);
        if (ret < 0) {
                dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret);
                return ret;
index 91761436709ae315551d2b7cb3fb0d2736ab1a95..8dff87ec6d99c5dca122dcdb5d3697157564cfa2 100644 (file)
@@ -1843,12 +1843,9 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
        }
 
        node = of_get_child_by_name(dev->udev->dev.of_node, "mdio");
-       if (node) {
-               ret = of_mdiobus_register(dev->mdiobus, node);
+       ret = of_mdiobus_register(dev->mdiobus, node);
+       if (node)
                of_node_put(node);
-       } else {
-               ret = mdiobus_register(dev->mdiobus);
-       }
        if (ret) {
                netdev_err(dev->net, "can't register MDIO bus\n");
                goto exit1;