]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Fix Ethernet init() return codes
authorBen Warren <biggerbadderben@gmail.com>
Wed, 9 Jan 2008 23:15:53 +0000 (18:15 -0500)
committerWolfgang Denk <wd@denx.de>
Thu, 10 Jan 2008 00:06:02 +0000 (01:06 +0100)
Change return values of init() functions in all Ethernet drivers to conform
to the following:

    >=0: Success
    <0:  Failure

All drivers going forward should return 0 on success.  Current drivers that
return 1 on success were left as-is to minimize changes.

Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Acked-By: Timur Tabi <timur@freescale.com>
13 files changed:
cpu/ixp/npe/npe.c
cpu/mpc8xx/fec.c
drivers/net/dc2114x.c
drivers/net/eepro100.c
drivers/net/macb.c
drivers/net/pcnet.c
drivers/net/rtl8139.c
drivers/net/rtl8169.c
drivers/net/tsec.c
drivers/net/tsi108_eth.c
drivers/net/uli526x.c
drivers/qe/uec.c
net/eth.c

index 7e4af441054bb1c3c44c81530b36a0f58bbc3c1b..a33b956975eaec6f71be9bc337da3683411a6f53 100644 (file)
@@ -408,25 +408,25 @@ static int npe_init(struct eth_device *dev, bd_t * bis)
        if (ixEthAccPortRxCallbackRegister(p_npe->eth_id, npe_rx_callback,
                                           (u32)p_npe) != IX_ETH_ACC_SUCCESS) {
                printf("can't register RX callback!\n");
-               return 0;
+               return -1;
        }
 
        if (ixEthAccPortTxDoneCallbackRegister(p_npe->eth_id, npe_tx_callback,
                                               (u32)p_npe) != IX_ETH_ACC_SUCCESS) {
                printf("can't register TX callback!\n");
-               return 0;
+               return -1;
        }
 
        npe_set_mac_address(dev);
 
        if (ixEthAccPortEnable(p_npe->eth_id) != IX_ETH_ACC_SUCCESS) {
                printf("can't enable port!\n");
-               return 0;
+               return -1;
        }
 
        p_npe->active = 1;
 
-       return 1;
+       return 0;
 }
 
 #if 0 /* test-only: probably have to deal with it when booting linux (for a clean state) */
index da473ca0b1f6af0d91cc40a19f93d22cb07dac6a..5a314137d91171bf3addfc4353e1d5b3902bd2b0 100644 (file)
@@ -727,7 +727,7 @@ static int fec_init (struct eth_device *dev, bd_t * bd)
 
                if (efis->actual_phy_addr == -1) {
                        printf ("Unable to discover phy!\n");
-                       return 0;
+                       return -1;
                }
 #else
                efis->actual_phy_addr = -1;
@@ -763,7 +763,7 @@ static int fec_init (struct eth_device *dev, bd_t * bd)
 
        efis->initialized = 1;
 
-       return 1;
+       return 0;
 }
 
 
index d5275dceb0fb6a8603f4881b16d32d4dc40fe4f8..723892261466d60c364b8362ea00121b0bd3c82a 100644 (file)
@@ -332,7 +332,7 @@ static int dc21x4x_init(struct eth_device* dev, bd_t* bis)
 
        if ((INL(dev, DE4X5_STS) & (STS_TS | STS_RS)) != 0) {
                printf("Error: Cannot reset ethernet controller.\n");
-               return 0;
+               return -1;
        }
 
 #ifdef CONFIG_TULIP_SELECT_MEDIA
@@ -382,7 +382,7 @@ static int dc21x4x_init(struct eth_device* dev, bd_t* bis)
 
        send_setup_frame(dev, bis);
 
-       return 1;
+       return 0;
 }
 
 static int dc21x4x_send(struct eth_device* dev, volatile void *packet, int length)
index 738146e6618e08e05656ca28ab879e38e0ff6fb2..96ed2710c21419286ed0ae02ac6db893b8a23442 100644 (file)
@@ -485,7 +485,7 @@ int eepro100_initialize (bd_t * bis)
 
 static int eepro100_init (struct eth_device *dev, bd_t * bis)
 {
-       int i, status = 0;
+       int i, status = -1;
        int tx_cur;
        struct descriptor *ias_cmd, *cfg_cmd;
 
@@ -598,7 +598,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
                goto Done;
        }
 
-       status = 1;
+       status = 0;
 
   Done:
        return status;
index 95cdc496cbac384e28c3a4b8ab090073a73248d7..6657d22926b55f4000c03095bb9b87af53247056 100644 (file)
@@ -423,12 +423,12 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
 #endif
 
        if (!macb_phy_init(macb))
-               return 0;
+               return -1;
 
        /* Enable TX and RX */
        macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE));
 
-       return 1;
+       return 0;
 }
 
 static void macb_halt(struct eth_device *netdev)
index 2af0e8f244f3384af18c67cb6df366c51fd43982..4e270c9f7b3f0fb15c3b853f15e748c60868892f 100644 (file)
@@ -402,7 +402,7 @@ static int pcnet_init(struct eth_device* dev, bd_t *bis)
     if (i <= 0) {
        printf("%s: TIMEOUT: controller init failed\n", dev->name);
        pcnet_reset (dev);
-       return 0;
+       return -1;
     }
 
     /*
@@ -410,7 +410,7 @@ static int pcnet_init(struct eth_device* dev, bd_t *bis)
      */
     pcnet_write_csr (dev, 0, 0x0002);
 
-    return 1;
+    return 0;
 }
 
 static int pcnet_send(struct eth_device* dev, volatile void *packet, int pkt_len)
index 23671800579a4119fafc9a13f42b7a35ed182850..4c248054c3eb7f76b1d9917ead2497617f193bf3 100644 (file)
@@ -273,10 +273,10 @@ static int rtl8139_probe(struct eth_device *dev, bd_t *bis)
 
        if (inb(ioaddr + MediaStatus) & MSRLinkFail) {
                printf("Cable not connected or other link failure\n");
-               return(0);
+               return -1 ;
        }
 
-       return 1;
+       return 0;
 }
 
 /* Serial EEPROM section. */
index 1d7f31cead401abacef9b0ff6810918d9edc9ff8..57ccbd964f7e5e453ba7cf862e6f457d2995f9ed 100644 (file)
@@ -624,7 +624,7 @@ static void rtl8169_init_ring(struct eth_device *dev)
 /**************************************************************************
 RESET - Finish setting up the ethernet interface
 ***************************************************************************/
-static void rtl_reset(struct eth_device *dev, bd_t *bis)
+static int rtl_reset(struct eth_device *dev, bd_t *bis)
 {
        int i;
 
@@ -660,6 +660,7 @@ static void rtl_reset(struct eth_device *dev, bd_t *bis)
 #ifdef DEBUG_RTL8169
        printf ("%s elapsed time : %d\n", __FUNCTION__, currticks()-stime);
 #endif
+       return 0;
 }
 
 /**************************************************************************
index 108cebd8797321b272e350a0ba76e95fe79ade66..25392f6862296c88bbfbf0bba822024cd45cb793 100644 (file)
@@ -232,7 +232,7 @@ int tsec_init(struct eth_device *dev, bd_t * bd)
        startup_tsec(dev);
 
        /* If there's no link, fail */
-       return priv->link;
+       return (priv->link ? 0 : -1);
 
 }
 
index 524e9daa4cb4a79ec99a4ffaaf5bcfb7afbda8f4..a09115e6ddd01156abd394ff3896f1113e1d5f58 100644 (file)
@@ -792,7 +792,7 @@ static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis)
            (dev->enetaddr[0] << 16);
 
        if (marvell_88e_phy_config(dev, &speed, &duplex) == 0)
-               return 0;
+               return -1;
 
        value =
            MAC_CONFIG_2_PREAMBLE_LENGTH(7) | MAC_CONFIG_2_PAD_CRC |
@@ -864,7 +864,7 @@ static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis)
        /* enable TX queue */
        reg_TX_CONTROL(base) = TX_CONTROL_GO | 0x01;
 
-       return 1;
+       return 0;
 }
 
 /*
index 1267c5798f06774a2f10731c52f5bda3257afe1b..8460f6928de3ea5819623e0ab341a5d53e0550d7 100644 (file)
@@ -279,12 +279,12 @@ static int uli526x_init_one(struct eth_device *dev, bd_t *bis)
        db->desc_pool_ptr = (uchar *)&desc_pool_array[0];
        db->desc_pool_dma_ptr = (dma_addr_t)&desc_pool_array[0];
        if (db->desc_pool_ptr == NULL)
-               return 0;
+               return -1;
 
        db->buf_pool_ptr = &buf_pool[0];
        db->buf_pool_dma_ptr = (dma_addr_t)&buf_pool[0];
        if (db->buf_pool_ptr == NULL)
-               return 0;
+               return -1;
 
        db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
        db->first_tx_desc_dma = db->desc_pool_dma_ptr;
@@ -331,7 +331,7 @@ static int uli526x_init_one(struct eth_device *dev, bd_t *bis)
        db->cr6_data |= ULI526X_TXTH_256;
        db->cr0_data = CR0_DEFAULT;
        uli526x_init(dev);
-       return 1;
+       return 0;
 }
 
 static void uli526x_disable(struct eth_device *dev)
index a27c12aa2dbced9435114f544d00618c553ebdb1..44cbea5785623d040a3bf432e47027db34c4edc3 100644 (file)
@@ -1129,7 +1129,7 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
                if (dev->enetaddr[0] & 0x01) {
                        printf("%s: MacAddress is multcast address\n",
                                 __FUNCTION__);
-                       return 0;
+                       return -1;
                }
                uec_set_mac_address(uec, dev->enetaddr);
                uec->the_first_run = 1;
@@ -1138,10 +1138,10 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
        err = uec_open(uec, COMM_DIR_RX_AND_TX);
        if (err) {
                printf("%s: cannot enable UEC device\n", dev->name);
-               return 0;
+               return -1;
        }
 
-       return uec->mii_info->link;
+       return (uec->mii_info->link ? 0 : -1);
 }
 
 static void uec_halt(struct eth_device* dev)
index d2fced8bbbcc053ba328ea4e1a0e59c724651c18..5d9e9c18898a52d0a7fd7121c976b0261184b738 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -433,7 +433,7 @@ int eth_init(bd_t *bis)
        do {
                debug ("Trying %s\n", eth_current->name);
 
-               if (!eth_current->init(eth_current,bis)) {
+               if (eth_current->init(eth_current,bis) >= 0) {
                        eth_current->state = ETH_STATE_ACTIVE;
 
                        return 0;