]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: phy: Move fixed link code to separate routine
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Fri, 12 Oct 2018 11:25:34 +0000 (16:55 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 12 Oct 2018 13:34:05 +0000 (15:34 +0200)
This patch moves fixed-link functionality code to a separate
routine inorder to make it more modular and cleaner.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/phy/phy.c

index fd3dd556c8794f2524b0b1710b406394d21880a2..d1bf1673ab05df7e0487941239978f5c253cc329 100644 (file)
@@ -854,18 +854,21 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev)
        debug("%s connected to %s\n", dev->name, phydev->drv->name);
 }
 
+#ifdef CONFIG_PHY_FIXED
 #ifdef CONFIG_DM_ETH
-struct phy_device *phy_connect(struct mii_dev *bus, int addr,
-               struct udevice *dev, phy_interface_t interface)
+static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
+                                           struct udevice *dev,
+                                           phy_interface_t interface)
 #else
-struct phy_device *phy_connect(struct mii_dev *bus, int addr,
-               struct eth_device *dev, phy_interface_t interface)
+static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
+                                           struct eth_device *dev,
+                                           phy_interface_t interface)
 #endif
 {
        struct phy_device *phydev = NULL;
-#ifdef CONFIG_PHY_FIXED
        int sn;
        const char *name;
+
        sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
        while (sn > 0) {
                name = fdt_get_name(gd->fdt_blob, sn, NULL);
@@ -876,7 +879,26 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
                }
                sn = fdt_next_subnode(gd->fdt_blob, sn);
        }
+
+       return phydev;
+}
+#endif
+
+#ifdef CONFIG_DM_ETH
+struct phy_device *phy_connect(struct mii_dev *bus, int addr,
+                              struct udevice *dev, phy_interface_t interface)
+#else
+struct phy_device *phy_connect(struct mii_dev *bus, int addr,
+                              struct eth_device *dev,
+                              phy_interface_t interface)
 #endif
+{
+       struct phy_device *phydev = NULL;
+
+#ifdef CONFIG_PHY_FIXED
+       phydev = phy_connect_fixed(bus, dev, interface);
+#endif
+
        if (phydev == NULL)
                phydev = phy_find_by_mask(bus, 1 << addr, interface);