Re: [U-Boot] [PATCH 10/15 v2] Update the number of ethxaddr in reading system eeprom

2009-05-21 Thread Wolfgang Denk
Dear Timur Tabi,

In message  you 
wrote:
> On Thu, May 21, 2009 at 2:34 PM, Haiying Wang
>  wrote:
> > +printf("Warning: The number of MAC address > is greater"
> > +" than MAX_NUM_PORTS, force>  it to MAX_NUM_PORTS.\n");
>
> I think you meant to do this:
>
> printf("Warning: The number of MAC address is greater"
>   " than %u, force it to %u.\n", MAX_NUM_PORTS, MAX_NUM_POR> 
> TS);

Actually it should be "number of MAC addresses", i. e. plural.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Anyone who isn't confused here doesn't really know what's going on.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 10/15 v2] Update the number of ethxaddr in reading system eeprom

2009-05-21 Thread Timur Tabi
On Thu, May 21, 2009 at 2:34 PM, Haiying Wang
 wrote:
> +               printf("Warning: The number of MAC address is greater"
> +                       " than MAX_NUM_PORTS, force it to MAX_NUM_PORTS.\n");

I think you meant to do this:

printf("Warning: The number of MAC address is greater"
  " than %u, force it to %u.\n", MAX_NUM_PORTS, MAX_NUM_PORTS);

But since you defined MAX_NUM_PORTS, you should also do this:

u8 mac[MAX_NUM_PORTS][6]; /* 0x42 - 0x71 MAC addresses */

To indicate where the dependency on 8 comes from.

-- 
Timur Tabi
Linux kernel developer at Freescale
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 10/15 v2] Update the number of ethxaddr in reading system eeprom

2009-05-21 Thread Haiying Wang
We support up to 8 mac addresses in system eeprom, so we define the macro
MAX_NUM_PORTS to limit the mac_count to 8, and update the number of ethxaddr
according to mac_count.

Signed-off-by: Haiying Wang 
---
v2 change: define MAC_NUM_PORTS to limit the mac_count
 board/freescale/common/sys_eeprom.c |   16 +---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/board/freescale/common/sys_eeprom.c 
b/board/freescale/common/sys_eeprom.c
index 988cb94..671eb00 100644
--- a/board/freescale/common/sys_eeprom.c
+++ b/board/freescale/common/sys_eeprom.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2008 Freescale Semiconductor
+ * Copyright 2006, 2008-2009 Freescale Semiconductor
  * York Sun (york...@freescale.com)
  * Haiying Wang (haiying.w...@freescale.com)
  * Timur Tabi (ti...@freescale.com)
@@ -34,6 +34,8 @@
 #error "Please define either CONFIG_SYS_I2C_EEPROM_CCID or 
CONFIG_SYS_I2C_EEPROM_NXID"
 #endif
 
+#define MAX_NUM_PORTS  8
+
 /**
  * static eeprom: EEPROM layout for CCID or NXID formats
  *
@@ -119,7 +121,8 @@ static void show_eeprom(void)
e.date[3] & 0x80 ? "PM" : "");
 
/* Show MAC addresses  */
-   for (i = 0; i < min(e.mac_count, 8); i++) {
+   for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) {
+
u8 *p = e.mac[i];
 
printf("Eth%u: %02x:%02x:%02x:%02x:%02x:%02x\n", i,
@@ -404,7 +407,14 @@ int mac_read_from_eeprom(void)
}
}
 
-   for (i = 0; i < min(4, e.mac_count); i++) {
+   /* Check the number of MAC address which is limited to MAX_NUM_PORTS */
+   if (e.mac_count > MAX_NUM_PORTS) {
+   printf("Warning: The number of MAC address is greater"
+   " than MAX_NUM_PORTS, force it to MAX_NUM_PORTS.\n");
+   e.mac_count = MAX_NUM_PORTS;
+   }
+
+   for (i = 0; i < e.mac_count; i++) {
if (memcmp(&e.mac[i], "\0\0\0\0\0\0", 6) &&
memcmp(&e.mac[i], "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) {
char ethaddr[18];
-- 
1.6.0.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot