]> git.sur5r.net Git - u-boot/commitdiff
net: abort network initialization if the PHY driver fails
authorTimur Tabi <timur@freescale.com>
Mon, 9 Jul 2012 08:52:43 +0000 (08:52 +0000)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 11 Jul 2012 18:15:30 +0000 (13:15 -0500)
Now that phy_startup() can return an actual error code, check for that error
code and abort network initialization if the PHY fails.

Signed-off-by: Timur Tabi <timur@freescale.com>
Acked-by: Nobuhiro Iwamamatsu <nobuhiro.iwamatsu.yj@renesas.com> (sh_eth part)
Acked-by: Stephan Linz <linz@li-pro.net> (Xilinx part, xilinx_axi_emac and xilinx_ll_temac)
Reviewed-by: Marek Vasut <marex@denx.de> (FEC part)
drivers/net/fec_mxc.c
drivers/net/fm/eth.c
drivers/net/sh_eth.c
drivers/net/tsec.c
drivers/net/xilinx_axi_emac.c
drivers/net/xilinx_ll_temac.c

index eee41d7c8b77f42c810739166a7b2790a69c098a..57005521899eaa6bb83c25b944b58726309ed4ea 100644 (file)
@@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)
                fec_eth_phy_config(edev);
        if (fec->phydev) {
                /* Start up the PHY */
-               phy_startup(fec->phydev);
+               int ret = phy_startup(fec->phydev);
+
+               if (ret) {
+                       printf("Could not initialize PHY %s\n",
+                              fec->phydev->dev->name);
+                       return ret;
+               }
                speed = fec->phydev->speed;
        } else {
                speed = _100BASET;
index f34f4db6b605da1173df86f19a4c06a9182762cd..2b616adb6e545803307ed53104fd2f8966cf919a 100644 (file)
@@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)
 {
        struct fm_eth *fm_eth;
        struct fsl_enet_mac *mac;
+#ifdef CONFIG_PHYLIB
+       int ret;
+#endif
 
        fm_eth = (struct fm_eth *)dev->priv;
        mac = fm_eth->mac;
@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)
        fmc_tx_port_graceful_stop_disable(fm_eth);
 
 #ifdef CONFIG_PHYLIB
-       phy_startup(fm_eth->phydev);
+       ret = phy_startup(fm_eth->phydev);
+       if (ret) {
+               printf("%s: Could not initialize\n", fm_eth->phydev->dev->name);
+               return ret;
+       }
 #else
        fm_eth->phydev->speed = SPEED_1000;
        fm_eth->phydev->link = 1;
index bb57e4d53a03a2c82f326479bdd6893d475456a3..268d88428c0227490d3e6e8e9f030883c71ea5d3 100644 (file)
@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
                goto err_phy_cfg;
        }
        phy = port_info->phydev;
-       phy_startup(phy);
+       ret = phy_startup(phy);
+       if (ret) {
+               printf(SHETHER_NAME ": phy startup failure\n");
+               return ret;
+       }
 
        val = 0;
 
index 3c1c8f0799c4177a1a4371e7cda27855510e61ec..f5e314b9ee06c366ae1360bc4b6b1f0452aa3eb6 100644 (file)
@@ -480,6 +480,7 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)
        int i;
        struct tsec_private *priv = (struct tsec_private *)dev->priv;
        tsec_t *regs = priv->regs;
+       int ret;
 
        /* Make sure the controller is stopped */
        tsec_halt(dev);
@@ -511,7 +512,12 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)
        startup_tsec(dev);
 
        /* Start up the PHY */
-       phy_startup(priv->phydev);
+       ret = phy_startup(priv->phydev);
+       if (ret) {
+               printf("Could not initialize PHY %s\n",
+                      priv->phydev->dev->name);
+               return ret;
+       }
 
        adjust_link(priv, priv->phydev);
 
index 7854a04cae1b7908b8bd43a480190915eab398aa..d77714440ad420f132d9d9af478d91b4af4a5624 100644 (file)
@@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev)
        phydev->advertising = phydev->supported;
        priv->phydev = phydev;
        phy_config(phydev);
-       phy_startup(phydev);
+       if (phy_startup(phydev)) {
+               printf("axiemac: could not initialize PHY %s\n",
+                      phydev->dev->name);
+               return 0;
+       }
 
        switch (phydev->speed) {
        case 1000:
index 27dafc15c00e8d54573dff7b1df3e137845c2ee6..b67153bec89d2004cc02a9d89653831340f764b3 100644 (file)
@@ -232,6 +232,7 @@ static void ll_temac_halt(struct eth_device *dev)
 static int ll_temac_init(struct eth_device *dev, bd_t *bis)
 {
        struct ll_temac *ll_temac = dev->priv;
+       int ret;
 
        printf("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n",
                dev->name, dev->index, dev->iobase);
@@ -240,7 +241,12 @@ static int ll_temac_init(struct eth_device *dev, bd_t *bis)
                return -1;
 
        /* Start up the PHY */
-       phy_startup(ll_temac->phydev);
+       ret = phy_startup(ll_temac->phydev);
+       if (ret) {
+               printf("%s: Could not initialize PHY %s\n",
+                      dev->name, ll_temac->phydev->dev->name);
+               return ret;
+       }
 
        if (!ll_temac_adjust_link(dev)) {
                ll_temac_halt(dev);