Merge branch 'master' of git://git.denx.de/u-boot-usb
[oweals/u-boot.git] / drivers / net / uli526x.c
index 79d29ae82200fac7d4f5de69df2e5b67ba412af0..a4624e1734df9977fe210eb57e13dcf7a6698ad8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Copyright 2007, 2010 Freescale Semiconductor, Inc.
  *
  * Author: Roy Zang <tie-fei.zang@freescale.com>, Sep, 2007
  *
 #include <common.h>
 #include <malloc.h>
 #include <net.h>
+#include <netdev.h>
 #include <asm/io.h>
 #include <pci.h>
 #include <miiphy.h>
 
 /* some kernel function compatible define */
 
-#if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI) && \
-       defined(CONFIG_ULI526X)
-
 #undef DEBUG
 
 /* Board/System/Debug information/definition */
@@ -227,7 +225,12 @@ int uli526x_initialize(bd_t *bis)
                iobase &= ~0xf;
 
                dev = (struct eth_device *)malloc(sizeof *dev);
-               sprintf(dev->name, "uli526x#%d\n", card_number);
+               if (!dev) {
+                       printf("uli526x: Can not allocate memory\n");
+                       break;
+               }
+               memset(dev, 0, sizeof(*dev));
+               sprintf(dev->name, "uli526x#%d", card_number);
                db = (struct uli526x_board_info *)
                        malloc(sizeof(struct uli526x_board_info));
 
@@ -313,7 +316,8 @@ static int uli526x_init_one(struct eth_device *dev, bd_t *bis)
                        i));
 
        /* Set Node address */
-       if (((u16 *) db->srom)[0] == 0xffff || ((u16 *) db->srom)[0] == 0)
+       if (((db->srom[0] == 0xff) && (db->srom[1] == 0xff)) ||
+           ((db->srom[0] == 0x00) && (db->srom[1] == 0x00)))
        /* SROM absent, so write MAC address to ID Table */
                set_mac_addr(dev);
        else {          /*Exist SROM*/
@@ -566,7 +570,7 @@ static int uli526x_rx_packet(struct eth_device *dev)
                        /* error summary bit check */
                        if (rdes0 & 0x8000) {
                                /* This is a error packet */
-                               printf("Eroor: rdes0: %lx\n", rdes0);
+                               printf("Error: rdes0: %x\n", rdes0);
                        }
 
                        if (!(rdes0 & 0x8000) ||
@@ -993,4 +997,3 @@ static void set_mac_addr(struct eth_device *dev)
        udelay(10);
        return;
 }
-#endif