]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/eepro100.c
net: Fix build regression in cmd_pxe.c
[u-boot] / drivers / net / eepro100.c
index d6539c01aa9ef22cb116f3e375c07d2bdfab6bce..d2c8277de96242f81d66bff33e0689fa0b1a1e91 100644 (file)
@@ -194,14 +194,14 @@ struct descriptor {                       /* A generic descriptor. */
        unsigned char params[0];
 };
 
-#define CFG_CMD_EL             0x8000
-#define CFG_CMD_SUSPEND                0x4000
-#define CFG_CMD_INT            0x2000
-#define CFG_CMD_IAS            0x0001  /* individual address setup */
-#define CFG_CMD_CONFIGURE      0x0002  /* configure */
+#define CONFIG_SYS_CMD_EL              0x8000
+#define CONFIG_SYS_CMD_SUSPEND         0x4000
+#define CONFIG_SYS_CMD_INT             0x2000
+#define CONFIG_SYS_CMD_IAS             0x0001  /* individual address setup */
+#define CONFIG_SYS_CMD_CONFIGURE       0x0002  /* configure */
 
-#define CFG_STATUS_C           0x8000
-#define CFG_STATUS_OK          0x2000
+#define CONFIG_SYS_STATUS_C            0x8000
+#define CONFIG_SYS_STATUS_OK           0x2000
 
        /* Misc.
         */
@@ -242,8 +242,7 @@ static void purge_tx_ring (struct eth_device *dev);
 static void read_hw_addr (struct eth_device *dev, bd_t * bis);
 
 static int eepro100_init (struct eth_device *dev, bd_t * bis);
-static int eepro100_send (struct eth_device *dev, volatile void *packet,
-                                                 int length);
+static int eepro100_send(struct eth_device *dev, void *packet, int length);
 static int eepro100_recv (struct eth_device *dev);
 static void eepro100_halt (struct eth_device *dev);
 
@@ -321,7 +320,8 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,
 /* Check if given phyaddr is valid, i.e. there is a PHY connected.
  * Do this by checking model value field from ID2 register.
  */
-static struct eth_device* verify_phyaddr (char *devname, unsigned char addr)
+static struct eth_device* verify_phyaddr (const char *devname,
+                                               unsigned char addr)
 {
        struct eth_device *dev;
        unsigned short value;
@@ -334,7 +334,7 @@ static struct eth_device* verify_phyaddr (char *devname, unsigned char addr)
        }
 
        /* read id2 register */
-       if (get_phyreg(dev, addr, PHY_PHYIDR2, &value) != 0) {
+       if (get_phyreg(dev, addr, MII_PHYSID2, &value) != 0) {
                printf("%s: mii read timeout!\n", devname);
                return NULL;
        }
@@ -350,7 +350,7 @@ static struct eth_device* verify_phyaddr (char *devname, unsigned char addr)
        return dev;
 }
 
-static int eepro100_miiphy_read (char *devname, unsigned char addr,
+static int eepro100_miiphy_read(const char *devname, unsigned char addr,
                unsigned char reg, unsigned short *value)
 {
        struct eth_device *dev;
@@ -367,7 +367,7 @@ static int eepro100_miiphy_read (char *devname, unsigned char addr,
        return 0;
 }
 
-static int eepro100_miiphy_write (char *devname, unsigned char addr,
+static int eepro100_miiphy_write(const char *devname, unsigned char addr,
                unsigned char reg, unsigned short value)
 {
        struct eth_device *dev;
@@ -449,6 +449,11 @@ int eepro100_initialize (bd_t * bis)
                }
 
                dev = (struct eth_device *) malloc (sizeof *dev);
+               if (!dev) {
+                       printf("eepro100: Can not allocate memory\n");
+                       break;
+               }
+               memset(dev, 0, sizeof(*dev));
 
                sprintf (dev->name, "i82559#%d", card_number);
                dev->priv = (void *) devno; /* this have to come before bus_to_phys() */
@@ -529,7 +534,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
        tx_next = ((tx_next + 1) % NUM_TX_DESC);
 
        cfg_cmd = (struct descriptor *) &tx_ring[tx_cur];
-       cfg_cmd->command = cpu_to_le16 ((CFG_CMD_SUSPEND | CFG_CMD_CONFIGURE));
+       cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE));
        cfg_cmd->status = 0;
        cfg_cmd->link = cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next]));
 
@@ -537,7 +542,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
                        sizeof (i82558_config_cmd));
 
        if (!wait_for_eepro100 (dev)) {
-               printf ("Error---CFG_CMD_CONFIGURE: Can not reset ethernet controller.\n");
+               printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
                goto Done;
        }
 
@@ -545,7 +550,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
        OUTW (dev, SCB_M | CU_START, SCBCmd);
 
        for (i = 0;
-            !(le16_to_cpu (tx_ring[tx_cur].status) & CFG_STATUS_C);
+            !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
             i++) {
                if (i >= TOUT_LOOP) {
                        printf ("%s: Tx error buffer not ready\n", dev->name);
@@ -553,7 +558,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
                }
        }
 
-       if (!(le16_to_cpu (tx_ring[tx_cur].status) & CFG_STATUS_OK)) {
+       if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
                printf ("TX error status = 0x%08X\n",
                        le16_to_cpu (tx_ring[tx_cur].status));
                goto Done;
@@ -565,7 +570,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
        tx_next = ((tx_next + 1) % NUM_TX_DESC);
 
        ias_cmd = (struct descriptor *) &tx_ring[tx_cur];
-       ias_cmd->command = cpu_to_le16 ((CFG_CMD_SUSPEND | CFG_CMD_IAS));
+       ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS));
        ias_cmd->status = 0;
        ias_cmd->link = cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next]));
 
@@ -581,7 +586,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
        OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);
        OUTW (dev, SCB_M | CU_START, SCBCmd);
 
-       for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CFG_STATUS_C);
+       for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
                 i++) {
                if (i >= TOUT_LOOP) {
                        printf ("%s: Tx error buffer not ready\n",
@@ -590,7 +595,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
                }
        }
 
-       if (!(le16_to_cpu (tx_ring[tx_cur].status) & CFG_STATUS_OK)) {
+       if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
                printf ("TX error status = 0x%08X\n",
                        le16_to_cpu (tx_ring[tx_cur].status));
                goto Done;
@@ -602,7 +607,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
        return status;
 }
 
-static int eepro100_send (struct eth_device *dev, volatile void *packet, int length)
+static int eepro100_send(struct eth_device *dev, void *packet, int length)
 {
        int i, status = -1;
        int tx_cur;
@@ -640,7 +645,7 @@ static int eepro100_send (struct eth_device *dev, volatile void *packet, int len
        OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);
        OUTW (dev, SCB_M | CU_START, SCBCmd);
 
-       for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CFG_STATUS_C);
+       for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
                 i++) {
                if (i >= TOUT_LOOP) {
                        printf ("%s: Tx error buffer not ready\n", dev->name);
@@ -648,7 +653,7 @@ static int eepro100_send (struct eth_device *dev, volatile void *packet, int len
                }
        }
 
-       if (!(le16_to_cpu (tx_ring[tx_cur].status) & CFG_STATUS_OK)) {
+       if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
                printf ("TX error status = 0x%08X\n",
                        le16_to_cpu (tx_ring[tx_cur].status));
                goto Done;
@@ -685,7 +690,7 @@ static int eepro100_recv (struct eth_device *dev)
                        /* Pass the packet up to the protocol
                         * layers.
                         */
-                       NetReceive (rx_ring[rx_next].data, length);
+                       NetReceive((u8 *)rx_ring[rx_next].data, length);
                } else {
                        /* There was an error.
                         */
@@ -917,7 +922,6 @@ static void purge_tx_ring (struct eth_device *dev)
 
 static void read_hw_addr (struct eth_device *dev, bd_t * bis)
 {
-       u16 eeprom[0x40];
        u16 sum = 0;
        int i, j;
        int addr_len = read_eeprom (dev, 0, 6) == 0xffff ? 8 : 6;
@@ -925,7 +929,6 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)
        for (j = 0, i = 0; i < 0x40; i++) {
                u16 value = read_eeprom (dev, i, addr_len);
 
-               eeprom[i] = value;
                sum += value;
                if (i < 3) {
                        dev->enetaddr[j++] = value;