All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot
@ 2009-02-14  7:22 Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's Mike Frysinger
                   ` (26 more replies)
  0 siblings, 27 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

this set of patches aims to standardize the mac address handling in all of
u-boot by doing the following:
	- add helper funcs for working with mac addresses (binary & string)
	- convert all duplicated code to use aforementioned helper funcs
	- convert all places to get the mac address from the environment
	- drop the global data instances of bi_enet*addr
	- document the whole damned thing

ive taken pains to make sure the patchset doesnt break along the way (in
terms of doing bisection and such).  but in general, the interdependency
looks something like:
	- add util funcs
	- convert net/boards/drivers/cpu/commands from global data to env
	- convert arch/board.c init to not touch global data
	- remove global data from all arch headers

the ppc steps with load_sernum_ethaddr() are a little hairy due to the
spread of code and trying to make sure things don't break bisection.  but
the other option is to squash all these commits (the common ppc board code
as well as each individual board) into one change.  doesn't matter to me
either way.

currently this patch series is maintained in my tree:
	git://www.denx.de/git/u-boot-blackfin.git macaddr

Mike Frysinger (27):
  net: new utility functions for working with enetaddr's
  doc/README.enetaddr: document proper MAC usage
  Blackfin: bfin_mac: force boards to setup the MAC themselves
  net: get mac address from environment and use eth util funcs
  bdinfo: get mac address from environment
  bootvx: get mac address from environment
  lynxkdi: get mac address from environment
  nvedit: do not update global bi_enetaddr and do not call
    eth_set_enetaddr()
  AmigaOneG3SE/enet: get mac address from environment
  boards: get mac address from environment
  drivers/net/: get mac address from environment
  bcm570x: get mac address from environment
  cs8900: get mac address from environment
  sh_eth: get mac address from environment
  lan91c96/smc91111/smc911x: get mac address from environment
  cpu/: get mac address from environment
  npe: get mac address from environment
  lib_*/board.c: do not initialize bi_enet*addr in global data
  nx823: get mac address from environment
  arm: get mac address from environment
  cmc_pu2: get mac address from environment
  pcs440ep: get mac address from environment and move
    load_sernum_ethaddr() to board init
  kup4k/kup4x: rename load_sernum_ethaddr() to
    kup_load_sernum_ethaddr()
  tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
  ppc: do not initialize bi_enet*addr in global data
  drop now unused load_sernum_ethaddr() function
  remove bi_enet*addr from global data for all arches

 board/MAI/AmigaOneG3SE/enet.c           |   42 ++--------
 board/cmc_pu2/load_sernum_ethaddr.c     |   18 +----
 board/etin/debris/debris.c              |    6 +-
 board/keymile/mgcoge/mgcoge.c           |    4 +-
 board/keymile/mgsuvd/mgsuvd.c           |    4 +-
 board/kup/common/load_sernum_ethaddr.c  |    2 +-
 board/kup/kup4k/kup4k.c                 |    3 +
 board/kup/kup4x/kup4x.c                 |    4 +-
 board/m501sk/m501sk.c                   |    5 -
 board/mpl/vcma9/cmd_vcma9.c             |   11 +--
 board/muas3001/muas3001.c               |    4 +-
 board/netstal/common/nm_bsp.c           |   40 +++-------
 board/nx823/flash.c                     |    5 +-
 board/nx823/nx823.c                     |   41 ++++------
 board/pcs440ep/pcs440ep.c               |   31 +++----
 board/pn62/pn62.c                       |   24 ++----
 board/sixnet/sixnet.c                   |   11 +--
 board/tqc/tqm8xx/load_sernum_ethaddr.c  |    2 +-
 board/tqc/tqm8xx/tqm8xx.c               |    3 +
 board/xilinx/xilinx_enet/emac_adapter.c |    8 ++-
 common/cmd_bdinfo.c                     |  136 +++++++++----------------------
 common/cmd_elf.c                        |    6 +-
 common/cmd_nvedit.c                     |   24 +-----
 common/lynxkdi.c                        |    2 +-
 cpu/arm920t/at91rm9200/ether.c          |    8 +-
 cpu/ixp/npe/npe.c                       |   36 +++------
 cpu/mpc512x/cpu.c                       |    6 +-
 cpu/mpc5xxx/cpu.c                       |    6 +-
 cpu/mpc8260/ether_fcc.c                 |    4 +-
 cpu/mpc8260/ether_scc.c                 |    4 +-
 cpu/ppc4xx/cpu_init.c                   |   14 ++--
 doc/README.enetaddr                     |   96 ++++++++++++++++++++++
 drivers/net/3c589.c                     |    7 +-
 drivers/net/4xx_enet.c                  |   13 +--
 drivers/net/bcm570x.c                   |    4 +-
 drivers/net/bcm570x_lm.h                |    2 +-
 drivers/net/bfin_mac.c                  |   16 ++--
 drivers/net/bfin_mac.h                  |    2 +-
 drivers/net/cs8900.c                    |   58 ++++---------
 drivers/net/dc2114x.c                   |    9 ++-
 drivers/net/dm9000x.c                   |   27 ++-----
 drivers/net/enc28j60.c                  |    4 +-
 drivers/net/fsl_mcdmafec.c              |   11 ++-
 drivers/net/ks8695eth.c                 |    9 +--
 drivers/net/lan91c96.c                  |   79 ++++---------------
 drivers/net/mcffec.c                    |   10 +-
 drivers/net/rtl8019.c                   |   14 ++--
 drivers/net/rtl8169.c                   |    2 +-
 drivers/net/s3c4510b_eth.c              |    2 +-
 drivers/net/s3c4510b_eth.h              |    2 +-
 drivers/net/sh_eth.c                    |   28 ++-----
 drivers/net/smc91111.c                  |   76 ++++--------------
 drivers/net/smc911x.c                   |   15 ++--
 drivers/net/tigon3.c                    |    7 +-
 drivers/net/xilinx_emac.c               |   12 ++-
 drivers/net/xilinx_emaclite.c           |   11 ++-
 include/asm-arm/u-boot.h                |    5 -
 include/asm-avr32/u-boot.h              |    1 -
 include/asm-blackfin/u-boot.h           |    1 -
 include/asm-i386/u-boot.h               |    1 -
 include/asm-m68k/u-boot.h               |   13 ---
 include/asm-microblaze/u-boot.h         |    1 -
 include/asm-mips/u-boot.h               |    1 -
 include/asm-nios/u-boot.h               |    1 -
 include/asm-nios2/u-boot.h              |    1 -
 include/asm-ppc/u-boot.h                |   19 -----
 include/asm-sh/u-boot.h                 |    1 -
 include/asm-sparc/u-boot.h              |   12 ---
 include/common.h                        |    2 -
 include/configs/cmc_pu2.h               |    1 +
 include/net.h                           |    4 +
 lib_arm/board.c                         |   47 +++--------
 lib_blackfin/board.c                    |   48 +-----------
 lib_i386/board.c                        |   17 ----
 lib_m68k/board.c                        |   38 ---------
 lib_microblaze/board.c                  |    8 --
 lib_mips/board.c                        |    8 --
 lib_nios/board.c                        |    5 -
 lib_nios2/board.c                       |    5 -
 lib_ppc/board.c                         |   96 ----------------------
 lib_sh/board.c                          |   10 ---
 lib_sparc/board.c                       |   19 -----
 net/bootp.c                             |   13 +---
 net/eth.c                               |   79 +++++++++++-------
 net/net.c                               |   20 ++---
 post/cpu/mpc8xx/ether.c                 |    4 +-
 86 files changed, 497 insertions(+), 1014 deletions(-)
 create mode 100644 doc/README.enetaddr

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-16 22:28   ` Wolfgang Denk
  2009-02-14  7:22 ` [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage Mike Frysinger
                   ` (25 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Declare new utility functions for converting between the environment
variables (eth*addr) and the binary MAC address representation.  This way
we can unify all the random places that already do this kind of thing.

The functions in question:
	eth_parse_enetaddr - "..." -> {...}
	eth_getenv_enetaddr - env -> {...}
	eth_setenv_enetaddr - {...} -> env
	str_enetaddr - {...} -> "..."

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 include/net.h |    4 +++
 net/eth.c     |   79 ++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/include/net.h b/include/net.h
index bbe0d4b..25124be 100644
--- a/include/net.h
+++ b/include/net.h
@@ -119,6 +119,10 @@ extern struct eth_device *eth_get_dev(void);	/* get the current device MAC	*/
 extern struct eth_device *eth_get_dev_by_name(char *devname); /* get device	*/
 extern int eth_get_dev_index (void);		/* get the device index         */
 extern void eth_set_enetaddr(int num, char* a);	/* Set new MAC address		*/
+extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
+extern int eth_getenv_enetaddr(char *name, uchar *enetaddr);
+extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+extern char *str_enetaddr(char *buf, const uchar *enetaddr);
 
 extern int eth_init(bd_t *bis);			/* Initialize the device	*/
 extern int eth_send(volatile void *packet, int length);	   /* Send a packet	*/
diff --git a/net/eth.c b/net/eth.c
index b7ef09f..d8025d0 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -26,6 +26,43 @@
 #include <net.h>
 #include <miiphy.h>
 
+#ifdef CONFIG_CMD_NET
+char *str_enetaddr(char *buf, const uchar *enetaddr)
+{
+	sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+		enetaddr[0], enetaddr[1], enetaddr[2],
+		enetaddr[3], enetaddr[4], enetaddr[5]);
+	return buf;
+}
+
+void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
+{
+	char *end;
+	int i;
+	for (i = 0; i < 6; ++i) {
+		enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
+		if (addr)
+			addr = (*end) ? end + 1 : end;
+	}
+}
+
+int eth_getenv_enetaddr(char *name, uchar *enetaddr)
+{
+	int ret = 0;
+	char *addr = getenv(name);
+	if (!addr)
+		ret = -1;
+	eth_parse_enetaddr(addr, enetaddr);
+	return ret;
+}
+
+int eth_setenv_enetaddr(char *name, const uchar *enetaddr)
+{
+	char buf[20];
+	return setenv(name, str_enetaddr(buf, enetaddr));
+}
+#endif
+
 #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI)
 
 /*
@@ -131,8 +168,7 @@ int eth_initialize(bd_t *bis)
 {
 	char enetvar[32];
 	unsigned char env_enetaddr[6];
-	int i, eth_number = 0;
-	char *tmp, *end;
+	int eth_number = 0;
 
 	eth_devices = NULL;
 	eth_current = NULL;
@@ -172,13 +208,7 @@ int eth_initialize(bd_t *bis)
 			}
 
 			sprintf(enetvar, eth_number ? "eth%daddr" : "ethaddr", eth_number);
-			tmp = getenv (enetvar);
-
-			for (i=0; i<6; i++) {
-				env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
-				if (tmp)
-					tmp = (*end) ? end+1 : end;
-			}
+			eth_parse_enetaddr(getenv(enetvar), env_enetaddr);
 
 			if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
 				if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
@@ -186,16 +216,10 @@ int eth_initialize(bd_t *bis)
 				{
 					printf ("\nWarning: %s MAC addresses don't match:\n",
 						dev->name);
-					printf ("Address in SROM is         "
-					       "%02X:%02X:%02X:%02X:%02X:%02X\n",
-					       dev->enetaddr[0], dev->enetaddr[1],
-					       dev->enetaddr[2], dev->enetaddr[3],
-					       dev->enetaddr[4], dev->enetaddr[5]);
-					printf ("Address in environment is  "
-					       "%02X:%02X:%02X:%02X:%02X:%02X\n",
-					       env_enetaddr[0], env_enetaddr[1],
-					       env_enetaddr[2], env_enetaddr[3],
-					       env_enetaddr[4], env_enetaddr[5]);
+					printf ("Address in SROM is         %s\n",
+						str_enetaddr(enetvar, dev->enetaddr));
+					printf ("Address in environment is  %s\n",
+						str_enetaddr(enetvar, env_enetaddr));
 				}
 
 				memcpy(dev->enetaddr, env_enetaddr, 6);
@@ -224,19 +248,14 @@ int eth_initialize(bd_t *bis)
 void eth_set_enetaddr(int num, char *addr) {
 	struct eth_device *dev;
 	unsigned char enetaddr[6];
-	char *end;
-	int i;
+	char buf[20];
 
 	debug ("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr);
 
 	if (!eth_devices)
 		return;
 
-	for (i=0; i<6; i++) {
-		enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
-		if (addr)
-			addr = (*end) ? end+1 : end;
-	}
+	eth_parse_enetaddr(addr, enetaddr);
 
 	dev = eth_devices;
 	while(num-- > 0) {
@@ -246,12 +265,10 @@ void eth_set_enetaddr(int num, char *addr) {
 			return;
 	}
 
+	str_enetaddr(buf, enetaddr);
 	debug ( "Setting new HW address on %s\n"
-		"New Address is             %02X:%02X:%02X:%02X:%02X:%02X\n",
-		dev->name,
-		enetaddr[0], enetaddr[1],
-		enetaddr[2], enetaddr[3],
-		enetaddr[4], enetaddr[5]);
+		"New Address is             %s\n",
+		dev->name, buf);
 
 	memcpy(dev->enetaddr, enetaddr, 6);
 }
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-16 22:38   ` Wolfgang Denk
  2009-02-14  7:22 ` [U-Boot] [PATCH 03/27] Blackfin: bfin_mac: force boards to setup the MAC themselves Mike Frysinger
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 doc/README.enetaddr |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.enetaddr

diff --git a/doc/README.enetaddr b/doc/README.enetaddr
new file mode 100644
index 0000000..dd7c50d
--- /dev/null
+++ b/doc/README.enetaddr
@@ -0,0 +1,96 @@
+---------------------------------
+ Ethernet Address (MAC) Handling
+---------------------------------
+
+There are a variety of places in U-Boot where the MAC address is used, parsed,
+and stored.  This document covers proper usage of each location and the moving
+of data between them.
+
+-----------
+ Locations
+-----------
+
+Here are the places where MAC addresses might be stored:
+
+ - board-specific location (eeprom, dedicated flash, ...)
+	Note: only used when mandatory due to hardware design etc...
+
+ - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR)
+	Note: this is the preferred way to permanently store MAC addresses
+
+ - ethernet data (struct eth_device -> enetaddr)
+	Note: these are temporary copies of the MAC address which exist only
+	      after the respective init steps have run and only to make usage
+	      in other places easier (to avoid constant env lookup/parsing)
+
+-------
+ Usage
+-------
+
+If the hardware design mandates that the MAC address is stored in some special
+place (like EEPROM etc...), then the board specific init code (such as the
+board-specific misc_init_r() function) is responsible for locating the MAC
+address(es) and initializing the respective environment variable(s) from it.
+Note that this shall be done if, and only if, the environment does not already
+contain these environment variables, i.e. existing variable definitions must
+not be overwritten.
+
+During runtime, the ethernet layer will use the environment variables to sync
+the MAC addresses to the ethernet structures.  All ethernet driver code should
+then only use the enetaddr member of the eth_device structure.  This is done
+on every network command, so the ethernet copies will stay in sync.
+
+The common environment code will take care of passing environment changes to
+the global data.  This happens automatically whenever setenv() updates the
+relevant ethaddr variables.
+
+Any other common code that wishes to access the MAC address should then query
+the global data directly.  No one should be looking in the environment for any
+addresses.
+
+---------
+ Helpers
+---------
+
+To assist in the management of these layers, a few helper functions exist.  You
+should use these rather than attempt to do any kind of parsing/manipulation
+yourself as many common errors have arisen in the past.
+
+	* void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
+
+Convert a string representation of a MAC address to the binary version.
+char *addr = "00:11:22:33:44:55";
+uchar enetaddr[6];
+eth_parse_enetaddr(addr, enetaddr);
+/* enetaddr now equals { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } */
+
+	* int eth_getenv_enetaddr(char *name, uchar *enetaddr);
+
+Look up an environment variable and convert the stored address.  If the env var
+is not set, then the function returns -1.  Otherwise, the conversion occurs and
+returns 0.
+uchar enetaddr[6];
+if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+	/* "ethaddr" is not set in the environment */
+	... try and setup "ethaddr" in the env ...
+}
+/* enetaddr is now set to the value stored in the ethaddr env var */
+
+	* int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+
+Store the MAC address into the named environment variable.  The return value is
+the same as the setenv() function.
+uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
+eth_setenv_enetaddr("ethaddr", enetaddr);
+/* the "ethaddr" env var should now be set to "00:11:22:33:44:55" */
+
+	* char *str_enetaddr(char *buf, const uchar *enetaddr);
+
+Print the MAC address into the specified storage.  Caller should make sure the
+storage is sufficient (20 bytes is fine).  The pointer used for storage is
+returned.
+char buf[20];
+uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
+str_enetaddr(buf, enetaddr);
+printf("The MAC is %s\n", buf);
+/* the buf variable is now set to "00:11:22:33:44:55" */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 03/27] Blackfin: bfin_mac: force boards to setup the MAC themselves
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 04/27] net: get mac address from environment and use eth util funcs Mike Frysinger
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Since the on-chip MAC does not have an eeprom or similar interface, force
all Blackfin boards that use this driver to setup the board data with a
proper MAC.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 drivers/net/bfin_mac.c |   16 ++++++++--------
 drivers/net/bfin_mac.h |    2 +-
 lib_blackfin/board.c   |   48 ++----------------------------------------------
 3 files changed, 11 insertions(+), 55 deletions(-)

diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 23f934a..12d98c2 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -315,7 +315,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)
 		return -1;
 
 	/* Initialize EMAC address */
-	bfin_EMAC_setup_addr(bd);
+	bfin_EMAC_setup_addr(dev->enetaddr);
 
 	/* Initialize TX and RX buffer */
 	for (i = 0; i < PKTBUFSRX; i++) {
@@ -373,16 +373,16 @@ static void bfin_EMAC_halt(struct eth_device *dev)
 
 }
 
-void bfin_EMAC_setup_addr(bd_t *bd)
+void bfin_EMAC_setup_addr(uchar *enetaddr)
 {
 	*pEMAC_ADDRLO =
-		bd->bi_enetaddr[0] |
-		bd->bi_enetaddr[1] << 8 |
-		bd->bi_enetaddr[2] << 16 |
-		bd->bi_enetaddr[3] << 24;
+		enetaddr[0] |
+		enetaddr[1] << 8 |
+		enetaddr[2] << 16 |
+		enetaddr[3] << 24;
 	*pEMAC_ADDRHI =
-		bd->bi_enetaddr[4] |
-		bd->bi_enetaddr[5] << 8;
+		enetaddr[4] |
+		enetaddr[5] << 8;
 }
 
 ADI_ETHER_BUFFER *SetupRxBuffer(int no)
diff --git a/drivers/net/bfin_mac.h b/drivers/net/bfin_mac.h
index 084f533..8f467a3 100644
--- a/drivers/net/bfin_mac.h
+++ b/drivers/net/bfin_mac.h
@@ -61,6 +61,6 @@ static void bfin_EMAC_halt(struct eth_device *dev);
 static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet, int length);
 static int bfin_EMAC_recv(struct eth_device *dev);
 
-static void bfin_EMAC_setup_addr(bd_t *bd);
+void bfin_EMAC_setup_addr(uchar *enetaddr);
 
 #endif
diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c
index c223711..537f69a 100644
--- a/lib_blackfin/board.c
+++ b/lib_blackfin/board.c
@@ -106,10 +106,6 @@ static void display_global_data(void)
 	printf(" \\-bd: %x\n", gd->bd);
 	printf("   |-bi_baudrate: %x\n", bd->bi_baudrate);
 	printf("   |-bi_ip_addr: %x\n", bd->bi_ip_addr);
-	printf("   |-bi_enetaddr: %x %x %x %x %x %x\n",
-	       bd->bi_enetaddr[0], bd->bi_enetaddr[1],
-	       bd->bi_enetaddr[2], bd->bi_enetaddr[3],
-	       bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
 	printf("   |-bi_boot_params: %x\n", bd->bi_boot_params);
 	printf("   |-bi_memstart: %x\n", bd->bi_memstart);
 	printf("   |-bi_memsize: %x\n", bd->bi_memsize);
@@ -338,35 +334,6 @@ void board_init_r(gd_t * id, ulong dest_addr)
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
-#ifdef CONFIG_CMD_NET
-	/* board MAC address */
-	s = getenv("ethaddr");
-	if (s == NULL) {
-# ifndef CONFIG_ETHADDR
-#  if 0
-		if (!board_get_enetaddr(bd->bi_enetaddr)) {
-			char nid[20];
-			sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",
-				bd->bi_enetaddr[0], bd->bi_enetaddr[1],
-				bd->bi_enetaddr[2], bd->bi_enetaddr[3],
-				bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
-			setenv("ethaddr", nid);
-		}
-#  endif
-# endif
-	} else {
-		int i;
-		char *e;
-		for (i = 0; i < 6; ++i) {
-			bd->bi_enetaddr[i] = simple_strtoul(s, &e, 16);
-			s = (*e) ? e + 1 : e;
-		}
-	}
-
-	/* IP Address */
-	bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-#endif
-
 	/* Initialize devices */
 	devices_init();
 	jumptable_init();
@@ -393,21 +360,10 @@ void board_init_r(gd_t * id, ulong dest_addr)
 #endif
 
 #ifdef CONFIG_CMD_NET
+	/* IP Address */
+	bd->bi_ip_addr = getenv_IPaddr("ipaddr");
 	printf("Net:   ");
 	eth_initialize(gd->bd);
-	if ((s = getenv("ethaddr"))) {
-# ifndef CONFIG_NET_MULTI
-		size_t i;
-		char *e;
-		for (i = 0; i < 6; ++i) {
-			bd->bi_enetaddr[i] = simple_strtoul(s, &e, 16);
-			s = (*e) ? e + 1 : e;
-		}
-# endif
-		printf("MAC:   %02X:%02X:%02X:%02X:%02X:%02X\n",
-			bd->bi_enetaddr[0], bd->bi_enetaddr[1], bd->bi_enetaddr[2],
-			bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
-	}
 #endif
 
 	display_global_data();
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 04/27] net: get mac address from environment and use eth util funcs
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (2 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 03/27] Blackfin: bfin_mac: force boards to setup the MAC themselves Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 05/27] bdinfo: get mac address from environment Mike Frysinger
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 net/bootp.c |   13 ++-----------
 net/net.c   |   20 ++++++++------------
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/net/bootp.c b/net/bootp.c
index 83465e4..c87049c 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -579,21 +579,12 @@ BootpRequest (void)
 #ifdef CONFIG_BOOTP_RANDOM_DELAY		/* Random BOOTP delay */
 	unsigned char bi_enetaddr[6];
 	int   reg;
-	char  *e,*s;
-	char tmp[64];
 	ulong tst1, tst2, sum, m_mask, m_value = 0;
 
 	if (BootpTry ==0) {
 		/* get our mac */
-		reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
-		s = (reg > 0) ? tmp : NULL;
+		eth_getenv_enetaddr("ethaddr", bi_enetaddr);
 
-		for (reg=0; reg<6; ++reg) {
-			bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
-			if (s) {
-				s = (*e) ? e+1 : e;
-			}
-		}
 #ifdef DEBUG
 		puts ("BootpRequest => Our Mac: ");
 		for (reg=0; reg<6; reg++) {
diff --git a/net/net.c b/net/net.c
index 459baf4..d4f9488 100644
--- a/net/net.c
+++ b/net/net.c
@@ -330,7 +330,7 @@ restart:
 #ifdef CONFIG_NET_MULTI
 	memcpy (NetOurEther, eth_get_dev()->enetaddr, 6);
 #else
-	memcpy (NetOurEther, bd->bi_enetaddr, 6);
+	eth_getenv_enetaddr("ethaddr", NetOurEther);
 #endif
 
 	NetState = NETLOOP_CONTINUE;
@@ -658,6 +658,9 @@ int
 NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 {
 	uchar *pkt;
+#ifdef ET_DEBUG
+	char buf[20];
+#endif
 
 	/* convert to new style broadcast */
 	if (dest == 0)
@@ -693,8 +696,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 	}
 
 #ifdef ET_DEBUG
-	printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
-		dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]);
+	printf("sending UDP to %08lx/%s\n", dest, str_enetaddr(buf, ether));
 #endif
 
 	pkt = (uchar *)NetTxPacket;
@@ -915,11 +917,7 @@ int CDPSendTrigger(void)
 #ifdef CONFIG_CDP_DEVICE_ID
 	*s++ = htons(CDP_DEVICE_ID_TLV);
 	*s++ = htons(CONFIG_CDP_DEVICE_ID);
-	memset(buf, 0, sizeof(buf));
-	sprintf(buf, CONFIG_CDP_DEVICE_ID_PREFIX "%02X%02X%02X%02X%02X%02X",
-		NetOurEther[0] & 0xff, NetOurEther[1] & 0xff,
-		NetOurEther[2] & 0xff, NetOurEther[3] & 0xff,
-		NetOurEther[4] & 0xff, NetOurEther[5] & 0xff);
+	str_enetaddr(buf, NetOurEther);
 	memcpy((uchar *)s, buf, 16);
 	s += 16 / 2;
 #endif
@@ -1319,10 +1317,8 @@ NetReceive(volatile uchar * inpkt, int len)
 			if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC)
 				break;
 #ifdef ET_DEBUG
-			printf("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n",
-				arp->ar_data[0], arp->ar_data[1],
-				arp->ar_data[2], arp->ar_data[3],
-				arp->ar_data[4], arp->ar_data[5]);
+			printf("Got ARP REPLY, set server/gtwy eth addr (%s)\n",
+				str_enetaddr(arp->ar_data));
 #endif
 
 			tmp = NetReadIP(&arp->ar_data[6]);
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 05/27] bdinfo: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (3 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 04/27] net: get mac address from environment and use eth util funcs Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 06/27] bootvx: " Mike Frysinger
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Add a new print_eth() function to automate the eth*addr env var acquisition
and display.  Affects all arches.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
CC: Scott McNutt <smcnutt@psyent.com>
CC: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
CC: Michal Simek <monstr@seznam.cz>
CC: Daniel Hellstrom <daniel@gaisler.com>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 common/cmd_bdinfo.c |  136 +++++++++++++++------------------------------------
 1 files changed, 40 insertions(+), 96 deletions(-)

diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index b2d6f84..1c2f875 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -32,6 +32,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static void print_num(const char *, ulong);
 
+static void print_eth(int idx);
+
 #ifndef CONFIG_ARM	/* PowerPC and other */
 static void print_lnum(const char *, u64);
 
@@ -40,7 +42,6 @@ static void print_str(const char *, const char *);
 
 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	int i;
 	bd_t *bd = gd->bd;
 	char buf[32];
 
@@ -91,44 +92,21 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	print_str ("pevfreq",	    strmhz(buf, bd->bi_pevfreq));
 #endif
 
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-
+	print_eth(0);
 #if defined(CONFIG_HAS_ETH1)
-	puts ("\neth1addr    =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
-	}
+	print_eth(1);
 #endif
-
 #if defined(CONFIG_HAS_ETH2)
-       puts ("\neth2addr    =");
-       for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]);
-	}
+	print_eth(2);
 #endif
-
 #if defined(CONFIG_HAS_ETH3)
-       puts ("\neth3addr    =");
-       for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]);
-	}
+	print_eth(3);
 #endif
-
 #if defined(CONFIG_HAS_ETH4)
-       puts ("\neth4addr    =");
-       for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet4addr[i]);
-	}
+	print_eth(4);
 #endif
-
 #if defined(CONFIG_HAS_ETH5)
-       puts ("\neth5addr    =");
-       for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet5addr[i]);
-	}
+	print_eth(5);
 #endif
 
 #ifdef CONFIG_HERMES
@@ -143,7 +121,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	int i;
 	bd_t *bd = gd->bd;
 
 	print_num ("memstart",		(ulong)bd->bi_memstart);
@@ -152,11 +129,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	print_num ("flashsize",		(ulong)bd->bi_flashsize);
 	print_num ("flashoffset",	(ulong)bd->bi_flashoffset);
 
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-	puts ("\nip_addr     = ");
+	print_eth(0);
+	puts ("ip_addr     = ");
 	print_IPaddr (bd->bi_ip_addr);
 	printf ("\nbaudrate    = %ld bps\n", bd->bi_baudrate);
 
@@ -167,9 +141,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-#if defined(CONFIG_CMD_NET)
-	int i;
-#endif
 	bd_t *bd = gd->bd;
 
 	print_num ("mem start",		(ulong)bd->bi_memstart);
@@ -184,11 +155,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 #endif
 
 #if defined(CONFIG_CMD_NET)
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-	puts ("\nip_addr     = ");
+	print_eth(0);
+	puts ("ip_addr     = ");
 	print_IPaddr (bd->bi_ip_addr);
 #endif
 
@@ -200,7 +168,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	int i;
 	bd_t *bd = gd->bd;
 	print_num ("mem start      ",	(ulong)bd->bi_memstart);
 	print_lnum ("mem size       ",	(u64)bd->bi_memsize);
@@ -212,11 +179,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	print_num ("sram size      ",	(ulong)bd->bi_sramsize);
 #endif
 #if defined(CONFIG_CMD_NET)
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-	puts ("\nip_addr     = ");
+	print_eth(0);
+	puts ("ip_addr     = ");
 	print_IPaddr (bd->bi_ip_addr);
 #endif
 	printf ("\nbaudrate    = %ld bps\n", (ulong)bd->bi_baudrate);
@@ -227,9 +191,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
 	bd_t *bd = gd->bd;
-#if defined(CONFIG_CMD_NET)
-	int i;
-#endif
 
 #ifdef DEBUG
 	print_num("bd address             ", (ulong) bd);
@@ -251,11 +212,8 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	       CONFIG_SYS_GBL_DATA_SIZE);
 
 #if defined(CONFIG_CMD_NET)
-	puts("ethaddr                =");
-	for (i = 0; i < 6; ++i) {
-		printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-	puts("\nIP addr                = ");
+	print_eth(0);
+	puts("IP addr                = ");
 	print_IPaddr(bd->bi_ip_addr);
 #endif
 	printf("\nbaudrate               = %6ld bps\n", bd->bi_baudrate);
@@ -267,7 +225,6 @@ static void print_str(const char *, const char *);
 
 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	int i;
 	bd_t *bd = gd->bd;
 	char buf[32];
 
@@ -294,33 +251,18 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	print_str ("vcofreq",		strmhz(buf, bd->bi_vcofreq));
 #endif
 #if defined(CONFIG_CMD_NET)
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-
+	print_eth(0);
 #if defined(CONFIG_HAS_ETH1)
-	puts ("\neth1addr    =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
-	}
+	print_eth(1);
 #endif
-
 #if defined(CONFIG_HAS_ETH2)
-	puts ("\neth2addr    =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]);
-	}
+	print_eth(2);
 #endif
-
 #if defined(CONFIG_HAS_ETH3)
-	puts ("\neth3addr    =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]);
-	}
+	print_eth(3);
 #endif
 
-	puts ("\nip_addr     = ");
+	puts ("ip_addr     = ");
 	print_IPaddr (bd->bi_ip_addr);
 #endif
 	printf ("\nbaudrate    = %ld bps\n", bd->bi_baudrate);
@@ -333,7 +275,6 @@ static void print_str(const char *, const char *);
 
 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	int i;
 	bd_t *bd = gd->bd;
 	char buf[32];
 
@@ -351,10 +292,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	print_num("flashsize",   (ulong)bd->bi_flashsize);
 	print_num("flashoffset", (ulong)bd->bi_flashoffset);
 
-	puts("ethaddr     =");
-	for (i = 0; i < 6; ++i)
-		printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	puts("\nip_addr     = ");
+	print_eth(0);
+	puts("ip_addr     = ");
 	print_IPaddr(bd->bi_ip_addr);
 	printf("\nbaudrate    = %d bps\n", bd->bi_baudrate);
 
@@ -365,7 +304,6 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	int i;
 	bd_t *bd = gd->bd;
 
 	print_num ("boot_params",	(ulong)bd->bi_boot_params);
@@ -375,11 +313,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	print_num ("flashsize",		(ulong)bd->bi_flashsize);
 	print_num ("flashoffset",	(ulong)bd->bi_flashoffset);
 
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-	puts ("\nip_addr     = ");
+	print_eth(0);
+	puts ("ip_addr     = ");
 	print_IPaddr (bd->bi_ip_addr);
 	printf ("\nbaudrate    = %d bps\n", bd->bi_baudrate);
 
@@ -405,12 +340,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 
 #if defined(CONFIG_CMD_NET)
-	puts ("ethaddr     =");
-	for (i=0; i<6; ++i) {
-		printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
-	}
-	puts  ( "\n"
-		"ip_addr     = ");
+	print_eth(0);
+	puts  ("ip_addr     = ");
 	print_IPaddr (bd->bi_ip_addr);
 #endif
 	printf ("\n"
@@ -426,6 +357,19 @@ static void print_num(const char *name, ulong value)
 	printf ("%-12s= 0x%08lX\n", name, value);
 }
 
+static void print_eth(int idx)
+{
+	char name[10], *val;
+	if (idx)
+		sprintf(name, "eth%iaddr", idx);
+	else
+		strcpy(name, "ethaddr");
+	val = getenv(name);
+	if (!val)
+		val = "(not set)";
+	printf("%-12s= %s\n", name, val);
+}
+
 #ifndef CONFIG_ARM
 static void print_lnum(const char *name, u64 value)
 {
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 06/27] bootvx: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (4 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 05/27] bdinfo: get mac address from environment Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 07/27] lynxkdi: " Mike Frysinger
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Niklaus Giger <niklaus.giger@member.fsf.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 common/cmd_elf.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 19e1249..4a3fff1 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -131,10 +131,12 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 #if defined(CONFIG_WALNUT)
 	tmp = (char *) CONFIG_SYS_NVRAM_BASE_ADDR + 0x500;
-	memcpy ((char *) tmp, (char *) &gd->bd->bi_enetaddr[3], 3);
+	eth_getenv_enetaddr("ethaddr", build_buf);
+	memcpy(tmp, &build_buf[3], 3);
 #elif defined(CONFIG_SYS_VXWORKS_MAC_PTR)
 	tmp = (char *) CONFIG_SYS_VXWORKS_MAC_PTR;
-	memcpy ((char *) tmp, (char *) &gd->bd->bi_enetaddr[0], 6);
+	eth_getenv_enetaddr("ethaddr", build_buf);
+	memcpy(tmp, build_buf, 6);
 #else
 	puts ("## Ethernet MAC address not copied to NV RAM\n");
 #endif
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 07/27] lynxkdi: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (5 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 06/27] bootvx: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 08/27] nvedit: do not update global bi_enetaddr and do not call eth_set_enetaddr() Mike Frysinger
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 common/lynxkdi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common/lynxkdi.c b/common/lynxkdi.c
index 5f12b0d..17b0607 100644
--- a/common/lynxkdi.c
+++ b/common/lynxkdi.c
@@ -33,7 +33,7 @@ void lynxkdi_boot (image_header_t *hdr)
 	kbd = gd->bd;
 	parms->clock_ref = kbd->bi_busfreq;
 	parms->dramsz = kbd->bi_memsize;
-	memcpy (parms->ethaddr, kbd->bi_enetaddr, 6);
+	eth_getenv_enetaddr("ethaddr", parms->ethaddr);
 	mtspr (SPRN_SPRG2, 0x0020);
 
 	/* Do a simple check for Bluecat so we can pass the
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 08/27] nvedit: do not update global bi_enetaddr and do not call eth_set_enetaddr()
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (6 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 07/27] lynxkdi: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 09/27] AmigaOneG3SE/enet: get mac address from environment Mike Frysinger
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Since the ethernet layer handles updating of device addresses itself from
the environment, there is no point in calling eth_set_enetaddr().

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 common/cmd_nvedit.c |   24 +-----------------------
 1 files changed, 1 insertions(+), 23 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 1fcb4c9..da69f9b 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -277,18 +277,6 @@ int _do_setenv (int flag, int argc, char *argv[])
 		*++env = '\0';
 	}
 
-#ifdef CONFIG_NET_MULTI
-	if (strncmp(name, "eth", 3) == 0) {
-		char *end;
-		int   num = simple_strtoul(name+3, &end, 10);
-
-		if (strcmp(end, "addr") == 0) {
-			eth_set_enetaddr(num, argv[2]);
-		}
-	}
-#endif
-
-
 	/* Delete only ? */
 	if ((argc < 3) || argv[2] == NULL) {
 		env_crc_update ();
@@ -336,18 +324,8 @@ int _do_setenv (int flag, int argc, char *argv[])
 	 * entry in the enviornment is changed
 	 */
 
-	if (strcmp(argv[1],"ethaddr") == 0) {
-		char *s = argv[2];	/* always use only one arg */
-		char *e;
-		for (i=0; i<6; ++i) {
-			bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
-			if (s) s = (*e) ? e+1 : e;
-		}
-#ifdef CONFIG_NET_MULTI
-		eth_set_enetaddr(0, argv[2]);
-#endif
+	if (strcmp(argv[1],"ethaddr") == 0)
 		return 0;
-	}
 
 	if (strcmp(argv[1],"ipaddr") == 0) {
 		char *s = argv[2];	/* always use only one arg */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 09/27] AmigaOneG3SE/enet: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (7 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 08/27] nvedit: do not update global bi_enetaddr and do not call eth_set_enetaddr() Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 10/27] boards: " Mike Frysinger
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

Always use the MAC address that is stored in the environment first before
falling back to the ROM.  This also cuts out any comparison steps: if the
mac in the env is sane, the ROM is never consulted.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Thomas Frieden <ThomasF@hyperion-entertainment.com>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/MAI/AmigaOneG3SE/enet.c |   42 +++++++---------------------------------
 1 files changed, 8 insertions(+), 34 deletions(-)

diff --git a/board/MAI/AmigaOneG3SE/enet.c b/board/MAI/AmigaOneG3SE/enet.c
index 0b4dfe6..ac969a9 100644
--- a/board/MAI/AmigaOneG3SE/enet.c
+++ b/board/MAI/AmigaOneG3SE/enet.c
@@ -600,7 +600,7 @@ static int eth_3com_init (struct eth_device *dev, bd_t * bis)
 	ias_cmd = (struct descriptor *) &tx_ring[tx_cur];
 	ias_cmd->status = cpu_to_le32 (1 << 31);	/* set DnIndicate bit.                  */
 	ias_cmd->next = 0;
-	ias_cmd->addr = cpu_to_le32 ((u32) & bis->bi_enetaddr[0]);
+	ias_cmd->addr = cpu_to_le32 ((u32) dev->enetaddr);
 	ias_cmd->length = cpu_to_le32 (6 | LAST_FRAG);
 
 	/* Tell the adapter where the TX ring is located */
@@ -787,6 +787,10 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)
 	unsigned int checksum = 0;
 	int i, j, timer;
 
+	/* First, try the env ... if that works, we're all done! */
+	if (eth_getenv_enetaddr("ethaddr", hw_addr))
+		goto Done;
+
 	/* Read the station address from the EEPROM. */
 
 	EL3WINDOW (dev, 0);
@@ -827,40 +831,10 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)
 		hw_addr[j + 1] = (u8) ((ETH_INW (dev, j) >> 8) & 0xff);
 	}
 
-	for (i = 0; i < ETH_ALEN; i++) {
-		if (hw_addr[i] != bis->bi_enetaddr[i]) {
-/*			printf("Warning: HW address don't match:\n"); */
-/*			printf("Address in 3Com Window 2 is	    " */
-/*			       "%02X:%02X:%02X:%02X:%02X:%02X\n", */
-/*			       hw_addr[0], hw_addr[1], hw_addr[2], */
-/*			       hw_addr[3], hw_addr[4], hw_addr[5]); */
-/*			printf("Address used by U-Boot is " */
-/*			       "%02X:%02X:%02X:%02X:%02X:%02X\n", */
-/*			       bis->bi_enetaddr[0], bis->bi_enetaddr[1],  */
-/*			       bis->bi_enetaddr[2], bis->bi_enetaddr[3],  */
-/*			       bis->bi_enetaddr[4], bis->bi_enetaddr[5]); */
-/*			goto Done; */
-			char buffer[256];
-
-			if (bis->bi_enetaddr[0] == 0
-			    && bis->bi_enetaddr[1] == 0
-			    && bis->bi_enetaddr[2] == 0
-			    && bis->bi_enetaddr[3] == 0
-			    && bis->bi_enetaddr[4] == 0
-			    && bis->bi_enetaddr[5] == 0) {
-
-				sprintf (buffer,
-					 "%02X:%02X:%02X:%02X:%02X:%02X",
-					 hw_addr[0], hw_addr[1], hw_addr[2],
-					 hw_addr[3], hw_addr[4], hw_addr[5]);
-				setenv ("ethaddr", buffer);
-			}
-		}
-	}
-
-	for (i = 0; i < ETH_ALEN; i++)
-		dev->enetaddr[i] = hw_addr[i];
+	/* Save the result in the environment */
+	eth_setenv_enetaddr("ethaddr", hw_addr);
 
 Done:
+	memcpy(dev->enetaddr, hw_addr, 6);
 	return;
 }
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 10/27] boards: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (8 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 09/27] AmigaOneG3SE/enet: get mac address from environment Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-16 22:46   ` Wolfgang Denk
  2009-02-14  7:22 ` [U-Boot] [PATCH 11/27] drivers/net/: " Mike Frysinger
                   ` (16 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The boards that get converted here to use the environment for the mac
address rather than global data:
	debris
	mgcoge
	mgsuvd
	muas3001
	netstal
	pn62
	sixnet
	vcma9
	xilinx (the ones that use xilinx_enet)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Sangmoon Kim <dogoil@etinsys.com>
CC: Heiko Schocher <hs@denx.de>
CC: David M?ller <d.mueller@elsoft.ch>
CC: Niklaus Giger <niklaus.giger@netstal.com>
CC: Wolfgang Grandegger <wg@denx.de>
CC: Dave Ellis <DGE@sixnetio.com>
CC: Ricardo Ribalda <ricardo.ribalda@uam.es>
---
 board/etin/debris/debris.c              |    6 +++-
 board/keymile/mgcoge/mgcoge.c           |    4 ++-
 board/keymile/mgsuvd/mgsuvd.c           |    4 ++-
 board/mpl/vcma9/cmd_vcma9.c             |   11 +++-----
 board/muas3001/muas3001.c               |    4 ++-
 board/netstal/common/nm_bsp.c           |   40 +++++++-----------------------
 board/pn62/pn62.c                       |   24 ++++++------------
 board/sixnet/sixnet.c                   |   11 +++-----
 board/xilinx/xilinx_enet/emac_adapter.c |    8 ++++-
 9 files changed, 45 insertions(+), 67 deletions(-)

diff --git a/board/etin/debris/debris.c b/board/etin/debris/debris.c
index 227c49a..3dec7cc 100644
--- a/board/etin/debris/debris.c
+++ b/board/etin/debris/debris.c
@@ -174,8 +174,10 @@ void nvram_write(long dest, const void *src, size_t count)
 int misc_init_r(void)
 {
 	/* Write ethernet addr in NVRAM for VxWorks */
-	nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
-			(char*)&gd->bd->bi_enetaddr[0], 6);
+	uchar ethaddr[6];
+	if (eth_getenv_enetaddr("ethaddr", ethaddr))
+		nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
+				ethaddr, 6);
 	return 0;
 }
 
diff --git a/board/keymile/mgcoge/mgcoge.c b/board/keymile/mgcoge/mgcoge.c
index 5c50739..54e7c25 100644
--- a/board/keymile/mgcoge/mgcoge.c
+++ b/board/keymile/mgcoge/mgcoge.c
@@ -325,6 +325,7 @@ void ft_blob_update (void *blob, bd_t *bd)
 {
 	ulong memory_data[2] = {0};
 	ulong flash_data[8] = {0};
+	uchar enetaddr[6];
 
 	memory_data[0] = cpu_to_be32 (bd->bi_memstart);
 	memory_data[1] = cpu_to_be32 (bd->bi_memsize);
@@ -341,8 +342,9 @@ void ft_blob_update (void *blob, bd_t *bd)
 	fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
 				sizeof (flash_data));
 	/* MAC addr */
+	eth_getenv_enetaddr("ethaddr", enetaddr);
 	fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
-				bd->bi_enetaddr, sizeof (u8) * 6);
+				enetaddr, sizeof (u8) * 6);
 }
 
 void ft_board_setup (void *blob, bd_t *bd)
diff --git a/board/keymile/mgsuvd/mgsuvd.c b/board/keymile/mgsuvd/mgsuvd.c
index 02baf62..dbdafeb 100644
--- a/board/keymile/mgsuvd/mgsuvd.c
+++ b/board/keymile/mgsuvd/mgsuvd.c
@@ -168,6 +168,7 @@ void ft_blob_update (void *blob, bd_t *bd)
 	ulong brg_data[1] = {0};
 	ulong memory_data[2] = {0};
 	ulong flash_data[4] = {0};
+	uchar enetaddr[6];
 
 	memory_data[0] = cpu_to_be32 (bd->bi_memstart);
 	memory_data[1] = cpu_to_be32 (bd->bi_memsize);
@@ -185,8 +186,9 @@ void ft_blob_update (void *blob, bd_t *bd)
 				sizeof (brg_data));
 
 	/* MAC adr */
+	eth_getenv_enetaddr("ethaddr", enetaddr);
 	fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
-				bd->bi_enetaddr, sizeof (u8) * 6);
+				enetaddr, sizeof (u8) * 6);
 }
 
 void ft_board_setup(void *blob, bd_t *bd)
diff --git a/board/mpl/vcma9/cmd_vcma9.c b/board/mpl/vcma9/cmd_vcma9.c
index 2748fa9..7d2aa3c 100644
--- a/board/mpl/vcma9/cmd_vcma9.c
+++ b/board/mpl/vcma9/cmd_vcma9.c
@@ -76,21 +76,18 @@ int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 			cs8900_e2prom_write(addr, data);
 		} else if (strcmp(argv[2], "setaddr") == 0) {
 			uchar addr, i, csum; ushort data;
+			uchar ethaddr[6];
 
 			/* check for valid ethaddr */
-			for (i = 0; i < 6; i++)
-				if (gd->bd->bi_enetaddr[i] != 0)
-					break;
-
-			if (i < 6) {
+			if (eth_getenv_enetaddr("ethaddr", ethaddr)) {
 				addr = 1;
 				data = 0x2158;
 				cs8900_e2prom_write(addr, data);
 				csum = cs8900_chksum(data);
 				addr++;
 				for (i = 0; i < 6; i+=2) {
-					data = gd->bd->bi_enetaddr[i+1] << 8 |
-					       gd->bd->bi_enetaddr[i];
+					data = enetaddr[i+1] << 8 |
+					       enetaddr[i];
 					cs8900_e2prom_write(addr, data);
 					csum += cs8900_chksum(data);
 					addr++;
diff --git a/board/muas3001/muas3001.c b/board/muas3001/muas3001.c
index 6b1e59f..8f83dd9 100644
--- a/board/muas3001/muas3001.c
+++ b/board/muas3001/muas3001.c
@@ -346,7 +346,9 @@ void ft_blob_update (void *blob, bd_t *bd)
 	/* MAC Adresse */
 	nodeoffset = fdt_path_offset (blob, "/soc/cpm/ethernet");
 	if (nodeoffset >= 0) {
-		ret = fdt_setprop (blob, nodeoffset, "mac-address", bd->bi_enetaddr,
+		uchar ethaddr[6];
+		eth_getenv_enetaddr("ethaddr", ethaddr);
+		ret = fdt_setprop (blob, nodeoffset, "mac-address", ethaddr,
 					sizeof (uchar) * 6);
 	if (ret < 0)
 		printf ("ft_blob_update): cannot set /soc/cpm/ethernet/mac-address "
diff --git a/board/netstal/common/nm_bsp.c b/board/netstal/common/nm_bsp.c
index e38b706..237f4ed 100644
--- a/board/netstal/common/nm_bsp.c
+++ b/board/netstal/common/nm_bsp.c
@@ -83,40 +83,20 @@ void set_params_for_sw_install(int install_requested, char *board_name )
 
 void common_misc_init_r(void)
 {
-	char *s = getenv(DEFAULT_ETH_ADDR);
-	char *e;
-	int i;
-	u32 serial = get_serial_number();
 	IPaddr_t ipaddr;
 	char *ipstring;
+	uchar ethaddr[6];
 
-	for (i = 0; i < 6; ++i) {
-		gd->bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-
-	if (gd->bd->bi_enetaddr[3] == 0 &&
-	    gd->bd->bi_enetaddr[4] == 0 &&
-	    gd->bd->bi_enetaddr[5] == 0) {
-		char ethaddr[22];
-
+	if (!eth_getenv_enetaddr(DEFAULT_ETH_ADDR, ethaddr)) {
 		/* Must be in sync with CONFIG_ETHADDR */
-		gd->bd->bi_enetaddr[0] = 0x00;
-		gd->bd->bi_enetaddr[1] = 0x60;
-		gd->bd->bi_enetaddr[2] = 0x13;
-		gd->bd->bi_enetaddr[3] = (serial >> 16) & 0xff;
-		gd->bd->bi_enetaddr[4] = (serial >>  8) & 0xff;
-		gd->bd->bi_enetaddr[5] = hcu_get_slot();
-		sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X%c",
-			gd->bd->bi_enetaddr[0], gd->bd->bi_enetaddr[1],
-			gd->bd->bi_enetaddr[2], gd->bd->bi_enetaddr[3],
-			gd->bd->bi_enetaddr[4],
-			gd->bd->bi_enetaddr[5],
-			0) ;
-		printf("%s: Setting eth %s serial 0x%x\n",  __FUNCTION__,
-		       ethaddr, serial);
-		setenv(DEFAULT_ETH_ADDR, ethaddr);
+		u32 serial = get_serial_number();
+		ethaddr[0] = 0x00;
+		ethaddr[1] = 0x60;
+		ethaddr[2] = 0x13;
+		ethaddr[3] = (serial >> 16) & 0xff;
+		ethaddr[4] = (serial >>  8) & 0xff;
+		ethaddr[5] = hcu_get_slot();
+		eth_setenv_enetaddr(DEFAULT_ETH_ADDR, ethaddr);
 	}
 
 	/* IP-Adress update */
diff --git a/board/pn62/pn62.c b/board/pn62/pn62.c
index 1b545bf..8cd3cb5 100644
--- a/board/pn62/pn62.c
+++ b/board/pn62/pn62.c
@@ -30,7 +30,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 static int get_serial_number (char *string, int size);
-static int get_mac_address (int id, u8 * mac, char *string, int size);
+static int get_mac_address (int id, u8 *mac);
 
 #ifdef CONFIG_SHOW_BOOT_PROGRESS
 void show_boot_progress (int phase)
@@ -138,18 +138,16 @@ int misc_init_r (void)
 	}
 	show_startup_phase (9);
 
-	if (getenv ("ethaddr") == NULL &&
-		get_mac_address (0, mac, str, sizeof (str)) > 0) {
-		setenv ("ethaddr", str);
-		memcpy (gd->bd->bi_enetaddr, mac, 6);
+	if (!eth_getenv_enetaddr("ethaddr", mac)) {
+		get_mac_address(0, mac);
+		eth_setenv_enetaddr("ethaddr", mac);
 	}
 	show_startup_phase (10);
 
 #ifdef CONFIG_HAS_ETH1
-	if (getenv ("eth1addr") == NULL &&
-		get_mac_address (1, mac, str, sizeof (str)) > 0) {
-		setenv ("eth1addr", str);
-		memcpy (gd->bd->bi_enet1addr, mac, 6);
+	if (!eth_getenv_enetaddr("eth1addr", mac)) {
+		get_mac_address(1, mac);
+		eth_setenv_enetaddr("eth1addr", mac);
 	}
 #endif /* CONFIG_HAS_ETH1 */
 	show_startup_phase (11);
@@ -177,15 +175,9 @@ static int get_serial_number (char *string, int size)
 	return i;
 }
 
-static int get_mac_address (int id, u8 * mac, char *string, int size)
+static int get_mac_address (int id, u8 *mac)
 {
-	if (size < 6 * 3)
-		return -1;
-
 	i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
-	return sprintf (string, "%02x:%02x:%02x:%02x:%02x:%02x",
-				mac[0], mac[1], mac[2],
-				mac[3], mac[4], mac[5]);
 }
 
 int board_eth_init(bd_t *bis)
diff --git a/board/sixnet/sixnet.c b/board/sixnet/sixnet.c
index 3ed581e..4fcd84b 100644
--- a/board/sixnet/sixnet.c
+++ b/board/sixnet/sixnet.c
@@ -264,6 +264,7 @@ int misc_init_r (void)
 	char* e;
 	int reg;
 	bd_t *bd = gd->bd;
+	uchar enetaddr[6];
 
 	memctl->memc_or2 = NVRAM_OR_PRELIM;
 	memctl->memc_br2 = NVRAM_BR_VALUE;
@@ -315,13 +316,9 @@ int misc_init_r (void)
 	 * is present it gets a unique address, otherwise it
 	 * shares the FEC address.
 	 */
-	s = getenv("eth1addr");
-	if (s == NULL)
-		s = getenv("ethaddr");
-	for (reg=0; reg<6; ++reg) {
-		bd->bi_enet1addr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e+1 : e;
+	if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+		eth_getenv_enetaddr("ethaddr", enetaddr);
+		eth_setenv_enetaddr("eth1addr", enetaddr);
 	}
 
 	return (0);
diff --git a/board/xilinx/xilinx_enet/emac_adapter.c b/board/xilinx/xilinx_enet/emac_adapter.c
index 0b100d2..35bcc4d 100644
--- a/board/xilinx/xilinx_enet/emac_adapter.c
+++ b/board/xilinx/xilinx_enet/emac_adapter.c
@@ -74,6 +74,7 @@ eth_init(bd_t * bis)
 {
 	u32 Options;
 	XStatus Result;
+	uchar enetaddr[6];
 
 #ifdef DEBUG
 	printf("EMAC Initialization Started\n\r");
@@ -87,11 +88,14 @@ eth_init(bd_t * bis)
 	/* make sure the Emac is stopped before it is started */
 	(void) XEmac_Stop(&Emac);
 
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 #ifdef CONFIG_ENV_IS_NOWHERE
-	memcpy(bis->bi_enetaddr, EMACAddr, 6);
+		memcpy(enetaddr, EMACAddr, 6);
+		eth_setenv_enetaddr("ethaddr", enetaddr);
 #endif
+	}
 
-	Result = XEmac_SetMacAddress(&Emac, bis->bi_enetaddr);
+	Result = XEmac_SetMacAddress(&Emac, enetaddr);
 	if (Result != XST_SUCCESS) {
 		return 0;
 	}
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 11/27] drivers/net/: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (9 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 10/27] boards: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 12/27] bcm570x: " Mike Frysinger
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The drivers that get converted here:
	3c589
	4xx_enet
	dc2114x
	dm9000x
	enc28j60
	fsl_mcdmafec
	ks8695eth
	mcffec
	rtl8019
	rtl8169
	s3c4510b_eth
	xilinx_emac
	xilinx_emaclite

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Rolf Offermanns <rof@sysgo.de>
CC: Stefan Roese <sr@denx.de>
CC: Sascha Hauer <saschahauer@web.de>
CC: TsiChung Liew <Tsi-Chung.Liew@freescale.com>
CC: Greg Ungerer <greg.ungerer@opengear.com>
CC: Xue Ligong <lgxue@hotmail.com>
CC: Wang Kehao <whut.edu.cn>
CC: Masami Komiya <mkomiya@sonare.it>
CC: Curt Brune <curt@cucy.com>
CC: Michal SIMEK <monstr@monstr.eu>
---
 drivers/net/3c589.c           |    7 +++++--
 drivers/net/4xx_enet.c        |   13 +++++--------
 drivers/net/dc2114x.c         |    9 ++++++---
 drivers/net/dm9000x.c         |   27 ++++++++-------------------
 drivers/net/enc28j60.c        |    4 +++-
 drivers/net/fsl_mcdmafec.c    |   11 ++++++-----
 drivers/net/ks8695eth.c       |    9 ++-------
 drivers/net/mcffec.c          |   10 +++++-----
 drivers/net/rtl8019.c         |   14 ++++++++------
 drivers/net/rtl8169.c         |    2 +-
 drivers/net/s3c4510b_eth.c    |    2 +-
 drivers/net/s3c4510b_eth.h    |    2 +-
 drivers/net/xilinx_emac.c     |   12 +++++++-----
 drivers/net/xilinx_emaclite.c |   11 +++++++----
 14 files changed, 65 insertions(+), 68 deletions(-)

diff --git a/drivers/net/3c589.c b/drivers/net/3c589.c
index 0cf8dff..f2c7d32 100644
--- a/drivers/net/3c589.c
+++ b/drivers/net/3c589.c
@@ -259,10 +259,13 @@ static void el_reset(bd_t *bd)
 
 	/* set mac addr */
 	{
-		unsigned char *mac_addr = bd->bi_enetaddr;
+		uchar mac_addr[6];
 		int i;
 
-		el_get_mac_addr( mac_addr );
+		if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+			el_get_mac_addr(mac_addr);
+			eth_setenv_enetaddr("ethaddr", mac_addr);
+		}
 
 		GO_WINDOW(2);
 		VX_BUSY_WAIT;
diff --git a/drivers/net/4xx_enet.c b/drivers/net/4xx_enet.c
index 1978269..918373b 100644
--- a/drivers/net/4xx_enet.c
+++ b/drivers/net/4xx_enet.c
@@ -1927,24 +1927,22 @@ int ppc_4xx_eth_initialize (bd_t * bis)
 		memcpy(ethaddr[eth_num], "\0\0\0\0\0\0", 6);
 
 	for (eth_num = 0; eth_num < LAST_EMAC_NUM; eth_num++) {
+		int ethaddr_idx = eth_num + CONFIG_EMAC_NR_START;
 		switch (eth_num) {
 		default:		/* fall through */
 		case 0:
-			memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
-			       bis->bi_enetaddr, 6);
+			eth_getenv_enetaddr("ethaddr", ethaddr[ethaddr_idx]);
 			hw_addr[eth_num] = 0x0;
 			break;
 #ifdef CONFIG_HAS_ETH1
 		case 1:
-			memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
-			       bis->bi_enet1addr, 6);
+			eth_getenv_enetaddr("eth1addr", ethaddr[ethaddr_idx]);
 			hw_addr[eth_num] = 0x100;
 			break;
 #endif
 #ifdef CONFIG_HAS_ETH2
 		case 2:
-			memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
-			       bis->bi_enet2addr, 6);
+			eth_getenv_enetaddr("eth2addr", ethaddr[ethaddr_idx]);
 #if defined(CONFIG_460GT)
 			hw_addr[eth_num] = 0x300;
 #else
@@ -1954,8 +1952,7 @@ int ppc_4xx_eth_initialize (bd_t * bis)
 #endif
 #ifdef CONFIG_HAS_ETH3
 		case 3:
-			memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
-			       bis->bi_enet3addr, 6);
+			eth_getenv_enetaddr("eth3addr", ethaddr[ethaddr_idx]);
 #if defined(CONFIG_460GT)
 			hw_addr[eth_num] = 0x400;
 #else
diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c
index c0137a7..5ae53e8 100644
--- a/drivers/net/dc2114x.c
+++ b/drivers/net/dc2114x.c
@@ -752,11 +752,14 @@ static void update_srom(struct eth_device *dev, bd_t *bis)
 		0x0000, 0x0000, 0x0000, 0x0000,	/* 38 */
 		0x0000, 0x0000, 0x0000, 0x4e07,	/* 3c */
 	};
+	uchar enetaddr[6];
 
 	/* Ethernet Addr... */
-	eeprom[0x0a] = ((bis->bi_enetaddr[1] & 0xff) << 8) | (bis->bi_enetaddr[0] & 0xff);
-	eeprom[0x0b] = ((bis->bi_enetaddr[3] & 0xff) << 8) | (bis->bi_enetaddr[2] & 0xff);
-	eeprom[0x0c] = ((bis->bi_enetaddr[5] & 0xff) << 8) | (bis->bi_enetaddr[4] & 0xff);
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+		return;
+	eeprom[0x0a] = (enetaddr[1] << 8) | enetaddr[0];
+	eeprom[0x0b] = (enetaddr[3] << 8) | enetaddr[2];
+	eeprom[0x0c] = (enetaddr[5] << 8) | enetaddr[4];
 
 	for (i=0; i<0x40; i++) {
 		write_srom(dev, DE4X5_APROM, i, eeprom[i]);
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index ffb739d..eb4c4ea 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -287,6 +287,8 @@ eth_init(bd_t * bd)
 	int i, oft, lnk;
 	u8 io_mode;
 	struct board_info *db = &dm9000_info;
+	uchar enetaddr[6];
+	char buf[20];
 
 	DM9000_DBG("eth_init()\n");
 
@@ -345,32 +347,19 @@ eth_init(bd_t * bd)
 	DM9000_iow(DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
 
 	/* Set Node address */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 #if !defined(CONFIG_AT91SAM9261EK)
-	for (i = 0; i < 6; i++)
-		((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i);
+		for (i = 0; i < 6; i++)
+			enetaddr[i] = read_srom_word(i);
+		eth_setenv_enetaddr("ethaddr", enetaddr);
 #endif
-
-	if (is_zero_ether_addr(bd->bi_enetaddr) ||
-	    is_multicast_ether_addr(bd->bi_enetaddr)) {
-		/* try reading from environment */
-		u8 i;
-		char *s, *e;
-		s = getenv ("ethaddr");
-		for (i = 0; i < 6; ++i) {
-			bd->bi_enetaddr[i] = s ?
-				simple_strtoul (s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
-		}
 	}
 
-	printf("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", bd->bi_enetaddr[0],
-	       bd->bi_enetaddr[1], bd->bi_enetaddr[2], bd->bi_enetaddr[3],
-	       bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
+	printf("MAC: %s\n", str_enetaddr(buf, enetaddr));
 
 	/* fill device MAC address registers */
 	for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
-		DM9000_iow(oft, bd->bi_enetaddr[i]);
+		DM9000_iow(oft, enetaddr[i]);
 	for (i = 0, oft = 0x16; i < 8; i++, oft++)
 		DM9000_iow(oft, 0xff);
 
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index 5c24b0d..3238a50 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -330,6 +330,7 @@ static int rxResetCounter = 0;
 int eth_init (bd_t * bis)
 {
 	unsigned char estatVal;
+	uchar enetaddr[6];
 
 	/* configure GPIO */
 	(*((volatile unsigned long *) IO1DIR)) |= ENC_SPI_SLAVE_CS;
@@ -351,7 +352,8 @@ int eth_init (bd_t * bis)
 
 	/* initialize controller */
 	encReset ();
-	encInit (bis->bi_enetaddr);
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	encInit (enetaddr);
 
 	m_nic_bfs (CTL_REG_ECON1, ENC_ECON1_RXEN);	/* enable receive */
 
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index d056010..35a6dfb 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -369,6 +369,7 @@ static int fec_init(struct eth_device *dev, bd_t * bd)
 	struct fec_info_dma *info = dev->priv;
 	volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);
 	int i;
+	uchar enetaddr[6];
 
 #ifdef ET_DEBUG
 	printf("fec_init: iobase 0x%08x ...\n", info->iobase);
@@ -397,11 +398,11 @@ static int fec_init(struct eth_device *dev, bd_t * bd)
 	fecp->eir = 0xffffffff;
 
 	/* Set station address   */
-	if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE) {
-		fec_set_hwaddr(fecp, bd->bi_enetaddr);
-	} else {
-		fec_set_hwaddr(fecp, bd->bi_enet1addr);
-	}
+	if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE)
+		eth_getenv_enetaddr("ethaddr", enetaddr);
+	else
+		eth_getenv_enetaddr("eth1addr", enetaddr);
+	fec_set_hwaddr(fecp, enetaddr);
 
 	/* Set Opcode/Pause Duration Register */
 	fecp->opd = 0x00010020;
diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
index 7f3e0c2..3777c40 100644
--- a/drivers/net/ks8695eth.c
+++ b/drivers/net/ks8695eth.c
@@ -102,6 +102,7 @@ void ks8695_getmac(void)
 void eth_reset(bd_t *bd)
 {
 	int i;
+	char addr[20];
 
 	debug ("%s(%d): eth_reset()\n", __FILE__, __LINE__);
 
@@ -150,13 +151,7 @@ void eth_reset(bd_t *bd)
 	ks8695_write(KS8695_LAN_DMA_RX, 0x71);
 	ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-	printf("KS8695 ETHERNET: ");
-	for (i = 0; (i < 5); i++) {
-		bd->bi_enetaddr[i] = eth_mac[i];
-		printf("%02x:", eth_mac[i]);
-	}
-	bd->bi_enetaddr[i] = eth_mac[i];
-	printf("%02x\n", eth_mac[i]);
+	printf("KS8695 ETHERNET: %s\n", str_enetaddr(addr, eth_mac));
 }
 
 /****************************************************************************/
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index 18240a8..64be5de 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -416,7 +416,7 @@ int fec_init(struct eth_device *dev, bd_t * bd)
 	struct fec_info_s *info = dev->priv;
 	volatile fec_t *fecp = (fec_t *) (info->iobase);
 	int i;
-	u8 *ea = NULL;
+	uchar ea[6];
 
 	fecpin_setclear(dev, 1);
 
@@ -444,25 +444,25 @@ int fec_init(struct eth_device *dev, bd_t * bd)
 	if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE) {
 #ifdef CONFIG_SYS_FEC1_IOBASE
 		volatile fec_t *fecp1 = (fec_t *) (CONFIG_SYS_FEC1_IOBASE);
-		ea = &bd->bi_enet1addr[0];
+		eth_getenv_enetaddr("eth1addr", ea);
 		fecp1->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp1->paur = (ea[4] << 24) | (ea[5] << 16);
 #endif
-		ea = &bd->bi_enetaddr[0];
+		eth_getenv_enetaddr("ethaddr", ea);
 		fecp->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp->paur = (ea[4] << 24) | (ea[5] << 16);
 	} else {
 #ifdef CONFIG_SYS_FEC0_IOBASE
 		volatile fec_t *fecp0 = (fec_t *) (CONFIG_SYS_FEC0_IOBASE);
-		ea = &bd->bi_enetaddr[0];
+		eth_getenv_enetaddr("ethaddr", ea);
 		fecp0->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp0->paur = (ea[4] << 24) | (ea[5] << 16);
 #endif
 #ifdef CONFIG_SYS_FEC1_IOBASE
-		ea = &bd->bi_enet1addr[0];
+		eth_getenv_enetaddr("eth1addr", ea);
 		fecp->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp->paur = (ea[4] << 24) | (ea[5] << 16);
diff --git a/drivers/net/rtl8019.c b/drivers/net/rtl8019.c
index 3ddf917..f516afe 100644
--- a/drivers/net/rtl8019.c
+++ b/drivers/net/rtl8019.c
@@ -91,6 +91,7 @@ void eth_halt (void)
 
 int eth_init (bd_t * bd)
 {
+	uchar enetaddr[6];
 	eth_reset ();
 	put_reg (RTL8019_COMMAND, RTL8019_PAGE0STOP);
 	put_reg (RTL8019_DATACONFIGURATION, 0x48);
@@ -105,12 +106,13 @@ int eth_init (bd_t * bd)
 	put_reg (RTL8019_INTERRUPTSTATUS, 0xff);
 	put_reg (RTL8019_INTERRUPTMASK, 0x11);	/*b; */
 	put_reg (RTL8019_COMMAND, RTL8019_PAGE1STOP);
-	put_reg (RTL8019_PHYSICALADDRESS0, bd->bi_enetaddr[0]);
-	put_reg (RTL8019_PHYSICALADDRESS1, bd->bi_enetaddr[1]);
-	put_reg (RTL8019_PHYSICALADDRESS2, bd->bi_enetaddr[2]);
-	put_reg (RTL8019_PHYSICALADDRESS3, bd->bi_enetaddr[3]);
-	put_reg (RTL8019_PHYSICALADDRESS4, bd->bi_enetaddr[4]);
-	put_reg (RTL8019_PHYSICALADDRESS5, bd->bi_enetaddr[5]);
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	put_reg (RTL8019_PHYSICALADDRESS0, enetaddr[0]);
+	put_reg (RTL8019_PHYSICALADDRESS1, enetaddr[1]);
+	put_reg (RTL8019_PHYSICALADDRESS2, enetaddr[2]);
+	put_reg (RTL8019_PHYSICALADDRESS3, enetaddr[3]);
+	put_reg (RTL8019_PHYSICALADDRESS4, enetaddr[4]);
+	put_reg (RTL8019_PHYSICALADDRESS5, enetaddr[5]);
 	put_reg (RTL8019_MULTIADDRESS0, 0x00);
 	put_reg (RTL8019_MULTIADDRESS1, 0x00);
 	put_reg (RTL8019_MULTIADDRESS2, 0x00);
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index e9f6391..f8c14b4 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -750,7 +750,7 @@ static int rtl_init(struct eth_device *dev, bd_t *bis)
 
 	/* Get MAC address.  FIXME: read EEPROM */
 	for (i = 0; i < MAC_ADDR_LEN; i++)
-		bis->bi_enetaddr[i] = dev->enetaddr[i] = RTL_R8(MAC0 + i);
+		dev->enetaddr[i] = RTL_R8(MAC0 + i);
 
 #ifdef DEBUG_RTL8169
 	printf("chipset = %d\n", tpc->chipset);
diff --git a/drivers/net/s3c4510b_eth.c b/drivers/net/s3c4510b_eth.c
index 6dcb244..818ed3d 100644
--- a/drivers/net/s3c4510b_eth.c
+++ b/drivers/net/s3c4510b_eth.c
@@ -100,7 +100,7 @@ int eth_init(bd_t *bis)
 	ETH *eth = &m_eth;
 
 	/* store our MAC address */
-	eth->m_mac = bis->bi_enetaddr;
+	eth_getenv_enetaddr("ethaddr", eth->m_mac);
 
 	/* setup DBMA and MAC */
 	PUT_REG( REG_BDMARXCON, ETH_BRxRS);   /* reset BDMA RX machine */
diff --git a/drivers/net/s3c4510b_eth.h b/drivers/net/s3c4510b_eth.h
index 048307f..18a52a7 100644
--- a/drivers/net/s3c4510b_eth.h
+++ b/drivers/net/s3c4510b_eth.h
@@ -296,7 +296,7 @@ typedef struct __ETH {
 	TX_FrameDescriptor  *m_baseTX_FD; /*  pointer to base TX frame descriptor    */
 	RX_FrameDescriptor   *m_curRX_FD; /*  pointer to current RX frame descriptor */
 	RX_FrameDescriptor  *m_baseRX_FD; /*  pointer to base RX frame descriptor    */
-	u8                        *m_mac; /*  pointer to our MAC address             */
+	u8                      m_mac[6]; /*  pointer to our MAC address             */
 } ETH;
 
 #endif
diff --git a/drivers/net/xilinx_emac.c b/drivers/net/xilinx_emac.c
index c7f1a2a..a489aa9 100644
--- a/drivers/net/xilinx_emac.c
+++ b/drivers/net/xilinx_emac.c
@@ -166,6 +166,7 @@ void eth_halt(void)
 
 int eth_init(bd_t * bis)
 {
+	uchar enetaddr[6];
 	u32 helpreg;
 	debug ("EMAC Initialization Started\n\r");
 
@@ -200,15 +201,16 @@ int eth_init(bd_t * bis)
 	helpreg &= ~(XEM_ECR_XMIT_ENABLE_MASK | XEM_ECR_RECV_ENABLE_MASK);
 	out_be32 (emac.baseaddress + XEM_ECR_OFFSET, helpreg);
 
-	if (!getenv("ethaddr")) {
-		memcpy(bis->bi_enetaddr, emacaddr, ENET_ADDR_LENGTH);
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(enetaddr, emacaddr, ENET_ADDR_LENGTH);
+		eth_setenv_enetaddr("ethaddr", enetaddr);
 	}
 
 	/* Set the device station address high and low registers */
-	helpreg = (bis->bi_enetaddr[0] << 8) | bis->bi_enetaddr[1];
+	helpreg = (enetaddr[0] << 8) | enetaddr[1];
 	out_be32 (emac.baseaddress + XEM_SAH_OFFSET, helpreg);
-	helpreg = (bis->bi_enetaddr[2] << 24) | (bis->bi_enetaddr[3] << 16) |
-			(bis->bi_enetaddr[4] << 8) | bis->bi_enetaddr[5];
+	helpreg = (enetaddr[2] << 24) | (enetaddr[3] << 16) |
+			(enetaddr[4] << 8) | enetaddr[5];
 	out_be32 (emac.baseaddress + XEM_SAL_OFFSET, helpreg);
 
 	helpreg = XEM_ECR_UNICAST_ENABLE_MASK | XEM_ECR_BROAD_ENABLE_MASK |
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 0e96ef1..cf39573 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -140,12 +140,15 @@ void eth_halt (void)
 
 int eth_init (bd_t * bis)
 {
+	uchar enetaddr[6];
+
 	debug ("EmacLite Initialization Started\n");
 	memset (&emaclite, 0, sizeof (xemaclite));
 	emaclite.baseaddress = XILINX_EMACLITE_BASEADDR;
 
-	if (!getenv("ethaddr")) {
-		memcpy(bis->bi_enetaddr, emacaddr, ENET_ADDR_LENGTH);
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(enetaddr, emacaddr, ENET_ADDR_LENGTH);
+		eth_setenv_enetaddr("ethaddr", enetaddr);
 	}
 
 /*
@@ -154,7 +157,7 @@ int eth_init (bd_t * bis)
 	/* Restart PING TX */
 	out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0);
 	/* Copy MAC address */
-	xemaclite_alignedwrite (bis->bi_enetaddr,
+	xemaclite_alignedwrite (enetaddr,
 		emaclite.baseaddress, ENET_ADDR_LENGTH);
 	/* Set the length */
 	out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);
@@ -167,7 +170,7 @@ int eth_init (bd_t * bis)
 #ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
 	/* The same operation with PONG TX */
 	out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0);
-	xemaclite_alignedwrite (bis->bi_enetaddr, emaclite.baseaddress +
+	xemaclite_alignedwrite (enetaddr, emaclite.baseaddress +
 		XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH);
 	out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);
 	out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET,
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 12/27] bcm570x: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (10 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 11/27] drivers/net/: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 13/27] cs8900: " Mike Frysinger
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Since the address is in the PLM_DEVICE_BLOCK structure already, there is
no need to pass the NodeAddress as a second parameter.  So drop the second
argument to the LM_SetMacAddress() function (and update the tigon3 driver
accordingly).

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: James F. Dougherty <jfd@broadcom.com>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 drivers/net/bcm570x.c    |    4 ++--
 drivers/net/bcm570x_lm.h |    2 +-
 drivers/net/tigon3.c     |    7 ++++---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bcm570x.c b/drivers/net/bcm570x.c
index 185764e..c250d44 100644
--- a/drivers/net/bcm570x.c
+++ b/drivers/net/bcm570x.c
@@ -450,8 +450,8 @@ int eth_init (bd_t * bis)
 			    + 1);
 	strcpy (pUmDevice->name, board_info[bcm570xDevices[i].board_id].name);
 
-	memcpy (pDevice->NodeAddress, bis->bi_enetaddr, 6);
-	LM_SetMacAddress (pDevice, bis->bi_enetaddr);
+	eth_getenv_enetaddr("ethaddr", pDevice->NodeAddress);
+	LM_SetMacAddress (pDevice);
 	/* Init queues  .. */
 	QQ_InitQueue (&pUmDevice->rx_out_of_buf_q.Container,
 		      MAX_RX_PACKET_DESC_COUNT);
diff --git a/drivers/net/bcm570x_lm.h b/drivers/net/bcm570x_lm.h
index 2ea6ca8..c07b767 100644
--- a/drivers/net/bcm570x_lm.h
+++ b/drivers/net/bcm570x_lm.h
@@ -371,7 +371,7 @@ LM_STATUS LM_Abort (PLM_DEVICE_BLOCK pDevice);
 LM_STATUS LM_MulticastAdd (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMcAddress);
 LM_STATUS LM_MulticastDel (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMcAddress);
 LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice);
-LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMacAddress);
+LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice);
 LM_STATUS LM_LoopbackAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pAddress);
 
 LM_UINT32 LM_GetCrcCounter (PLM_DEVICE_BLOCK pDevice);
diff --git a/drivers/net/tigon3.c b/drivers/net/tigon3.c
index e4e004e..33cb447 100644
--- a/drivers/net/tigon3.c
+++ b/drivers/net/tigon3.c
@@ -2463,7 +2463,7 @@ LM_STATUS LM_ResetAdapter (PLM_DEVICE_BLOCK pDevice)
 #endif				/* T3_JUMBO_RCV_ENTRY_COUNT */
 
 	/* Configure the MAC address. */
-	LM_SetMacAddress (pDevice, pDevice->NodeAddress);
+	LM_SetMacAddress (pDevice);
 
 	/* Initialize the transmit random backoff seed. */
 	Value32 = (pDevice->NodeAddress[0] + pDevice->NodeAddress[1] +
@@ -3428,7 +3428,7 @@ LM_STATUS LM_Halt (PLM_DEVICE_BLOCK pDevice)
 		     (pDevice->SubsystemId << 16) | pDevice->SubsystemVendorId);
 
 	/* Reprogram the MAC address. */
-	LM_SetMacAddress (pDevice, pDevice->NodeAddress);
+	LM_SetMacAddress (pDevice);
 
 	return LM_STATUS_SUCCESS;
 }				/* LM_Halt */
@@ -3833,9 +3833,10 @@ LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice)
 /*                                                                            */
 /* Return:                                                                    */
 /******************************************************************************/
-LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMacAddress)
+LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice)
 {
 	LM_UINT32 j;
+	PLM_UINT8 pMacAddress = pDevice->NodeAddress;
 
 	for (j = 0; j < 4; j++) {
 		REG_WR (pDevice, MacCtrl.MacAddr[j].High,
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 13/27] cs8900: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (11 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 12/27] bcm570x: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 14/27] sh_eth: " Mike Frysinger
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The cs8900 driver also changes slightly in that the hardware is not
consulted if the mac address in the env is sane.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Marius Groeger <mgroeger@sysgo.de>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 drivers/net/cs8900.c |   58 +++++++++++++++----------------------------------
 1 files changed, 18 insertions(+), 40 deletions(-)

diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index 35a9baf..7eb7e32 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -110,18 +110,15 @@ static void eth_reginit (void)
 	put_reg (PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx);
 }
 
-void cs8900_get_enetaddr (uchar * addr)
+void cs8900_get_enetaddr (void)
 {
 	int i;
-	unsigned char env_enetaddr[6];
-	char *tmp = getenv ("ethaddr");
-	char *end;
-
-	for (i=0; i<6; i++) {
-		env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
-		if (tmp)
-			tmp = (*end) ? end+1 : end;
-	}
+	uchar enetaddr[6];
+	char buf[20];
+
+	/* if the env is setup, then bail */
+	if (eth_getenv_enetaddr("ethaddr", enetaddr))
+		return;
 
 	/* verify chip id */
 	if (get_reg_init_bus (PP_ChipID) != 0x630e)
@@ -135,35 +132,13 @@ void cs8900_get_enetaddr (uchar * addr)
 			unsigned int Addr;
 
 			Addr = get_reg (PP_IA + i * 2);
-			addr[i * 2] = Addr & 0xFF;
-			addr[i * 2 + 1] = Addr >> 8;
+			enetaddr[i * 2] = Addr & 0xFF;
+			enetaddr[i * 2 + 1] = Addr >> 8;
 		}
 
-		if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6) != 0 &&
-		    memcmp(env_enetaddr, addr, 6) != 0) {
-			printf ("\nWarning: MAC addresses don't match:\n");
-			printf ("\tHW MAC address:  "
-				"%02X:%02X:%02X:%02X:%02X:%02X\n",
-				addr[0], addr[1],
-				addr[2], addr[3],
-				addr[4], addr[5] );
-			printf ("\t\"ethaddr\" value: "
-				"%02X:%02X:%02X:%02X:%02X:%02X\n",
-				env_enetaddr[0], env_enetaddr[1],
-				env_enetaddr[2], env_enetaddr[3],
-				env_enetaddr[4], env_enetaddr[5]) ;
-			debug ("### Set MAC addr from environment\n");
-			memcpy (addr, env_enetaddr, 6);
-		}
-		if (!tmp) {
-			char ethaddr[20];
-			sprintf (ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
-				 addr[0], addr[1],
-				 addr[2], addr[3],
-				 addr[4], addr[5]) ;
-			debug ("### Set environment from HW MAC addr = \"%s\"\n", ethaddr);
-			setenv ("ethaddr", ethaddr);
-		}
+		eth_setenv_enetaddr("ethaddr", enetaddr);
+		str_enetaddr(buf, enetaddr);
+		debug("### Set environment from HW MAC addr = \"%s\"\n", buf);
 	}
 }
 
@@ -178,6 +153,8 @@ void eth_halt (void)
 
 int eth_init (bd_t * bd)
 {
+	uchar *enetaddr[6];
+
 	/* verify chip id */
 	if (get_reg_init_bus (PP_ChipID) != 0x630e) {
 		printf ("CS8900 Ethernet chip not found?!\n");
@@ -186,9 +163,10 @@ int eth_init (bd_t * bd)
 
 	eth_reset ();
 	/* set the ethernet address */
-	put_reg (PP_IA + 0, bd->bi_enetaddr[0] | (bd->bi_enetaddr[1] << 8));
-	put_reg (PP_IA + 2, bd->bi_enetaddr[2] | (bd->bi_enetaddr[3] << 8));
-	put_reg (PP_IA + 4, bd->bi_enetaddr[4] | (bd->bi_enetaddr[5] << 8));
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	put_reg (PP_IA + 0, enetaddr[0] | (enetaddr[1] << 8));
+	put_reg (PP_IA + 2, enetaddr[2] | (enetaddr[3] << 8));
+	put_reg (PP_IA + 4, enetaddr[4] | (enetaddr[5] << 8));
 
 	eth_reginit ();
 	return 0;
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 14/27] sh_eth: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (12 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 13/27] cs8900: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 15/27] lan91c96/smc91111/smc911x: " Mike Frysinger
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The sh_eth driver can also be simplified a bit by using enetaddr member of
the eth_device structure.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
CC: Carlos Munoz <carlos@kenati.com>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 drivers/net/sh_eth.c |   28 ++++++----------------------
 1 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index ebe8588..a47c0dd 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -514,6 +514,7 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
 	int port = eth->port, ret = 0;
 	u32 val,  phy_status;
 	struct sh_eth_info *port_info = &eth->port_info[port];
+	struct eth_device *dev = port_info->dev;
 
 	/* Configure e-dmac registers */
 	outl((inl(EDMR(port)) & ~EMDR_DESC_R) | EDMR_EL, EDMR(port));
@@ -529,11 +530,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
 	outl(0, ECSIPR(port));
 
 	/* Set Mac address */
-	val = bd->bi_enetaddr[0] << 24 | bd->bi_enetaddr[1] << 16 |
-	    bd->bi_enetaddr[2] << 8 | bd->bi_enetaddr[3];
+	val = dev->enetaddr[0] << 24 | dev->enetaddr[1] << 16 |
+	    dev->enetaddr[2] << 8 | dev->enetaddr[3];
 	outl(val, MAHR(port));
 
-	val = bd->bi_enetaddr[4] << 8 | bd->bi_enetaddr[5];
+	val = dev->enetaddr[4] << 8 | dev->enetaddr[5];
 	outl(val, MALR(port));
 
 	outl(RFLR_RFL_MIN, RFLR(port));
@@ -589,24 +590,6 @@ static void sh_eth_stop(struct sh_eth_dev *eth)
 	outl(~EDRRR_R, EDRRR(eth->port));
 }
 
-static int sh_eth_get_mac(bd_t *bd)
-{
-	char *s, *e;
-
-	s = getenv("ethaddr");
-	if (s != NULL) {
-		int i;
-		for (i = 0; i < 6; ++i) {
-			bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
-		}
-	} else {
-		puts("Please set MAC address\n");
-	}
-	return 0;
-}
-
 int sh_eth_init(struct eth_device *dev, bd_t *bd)
 {
 	int ret = 0;
@@ -682,7 +665,8 @@ int sh_eth_initialize(bd_t *bd)
     /* Register Device to EtherNet subsystem  */
     eth_register(dev);
 
-	sh_eth_get_mac(bd);
+	if (!eth_getenv_enetaddr("ethaddr", dev->enetaddr))
+		puts("Please set MAC address\n");
 
 	return ret;
 
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 15/27] lan91c96/smc91111/smc911x: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (13 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 14/27] sh_eth: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-14  7:22 ` [U-Boot] [PATCH 16/27] cpu/: " Mike Frysinger
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Also, do not bother checking the EEPROM if the env is setup.  This
simplifies the code greatly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Rolf Offermanns <rof@sysgo.de>
CC: Erik Stahlman <erik@vt.edu>
CC: Daris A Nevil <dnevil@snmc.com>
CC: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/lan91c96.c |   79 +++++++++--------------------------------------
 drivers/net/smc91111.c |   76 +++++++++-------------------------------------
 drivers/net/smc911x.c  |   15 ++++-----
 3 files changed, 36 insertions(+), 134 deletions(-)

diff --git a/drivers/net/lan91c96.c b/drivers/net/lan91c96.c
index 318bdf4..59df00c 100644
--- a/drivers/net/lan91c96.c
+++ b/drivers/net/lan91c96.c
@@ -606,10 +606,8 @@ static int smc_open (bd_t *bd)
 	SMC_SELECT_BANK (1);
 
 	err = smc_get_ethaddr (bd);	/* set smc_mac_addr, and sync it with u-boot globals */
-	if (err < 0) {
-		memset (bd->bi_enetaddr, 0, 6); /* hack to make error stick! upper code will abort if not set */
-		return (-1);	/* upper code ignores this, but NOT bi_enetaddr */
-	}
+	if (err < 0)
+		return -1;
 #ifdef USE_32_BIT
 	for (i = 0; i < 6; i += 2) {
 		word address;
@@ -869,69 +867,22 @@ static int smc_hw_init ()
 
 int smc_get_ethaddr (bd_t * bd)
 {
-	int env_size = 0;
-	int rom_valid = 0;
-	int env_present = 0;
-	int reg = 0;
-	char *s = NULL;
-	char *e = NULL;
-	char *v_mac, es[] = "11:22:33:44:55:66";
-	char s_env_mac[64];
-	uchar v_env_mac[6];
-	uchar v_rom_mac[6];
-
-	env_size = getenv_r ("ethaddr", s_env_mac, sizeof (s_env_mac));
-	if (env_size != sizeof(es)) {	/* Ignore if env is bad or not set */
-		printf ("\n*** Warning: ethaddr is not set properly, ignoring!!\n");
-	} else {
-		env_present = 1;
-		s = s_env_mac;
-
-		for (reg = 0; reg < 6; ++reg) { /* turn string into mac value */
-			v_env_mac[reg] = s ? simple_strtoul (s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
+	uchar v_mac[6];
+	char buf[20];
+
+	if (!eth_getenv_enetaddr("ethaddr", v_mac)) {
+		/* get ROM mac value if any */
+		if (!get_rom_mac(v_mac)) {
+			printf("\n*** ERROR: ethaddr is NOT set !!\n");
+			return -1;
 		}
+		eth_setenv_enetaddr("ethaddr", v_mac);
 	}
 
-	rom_valid = get_rom_mac (v_rom_mac);	/* get ROM mac value if any */
-
-	if (!env_present) {	/* if NO env */
-		if (rom_valid) {	/* but ROM is valid */
-			v_mac = (char *)v_rom_mac;
-			sprintf (s_env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
-				 v_mac[0], v_mac[1], v_mac[2], v_mac[3],
-				 v_mac[4], v_mac[5]);
-			setenv ("ethaddr", s_env_mac);
-		} else {	/* no env, bad ROM */
-			printf ("\n*** ERROR: ethaddr is NOT set !!\n");
-			return (-1);
-		}
-	} else {		/* good env, don't care ROM */
-		v_mac = (char *)v_env_mac;	/* always use a good env over a ROM */
-	}
-
-	if (env_present && rom_valid) { /* if both env and ROM are good */
-		if (memcmp (v_env_mac, v_rom_mac, 6) != 0) {
-			printf ("\nWarning: MAC addresses don't match:\n");
-			printf ("\tHW MAC address:  "
-				"%02X:%02X:%02X:%02X:%02X:%02X\n",
-				v_rom_mac[0], v_rom_mac[1],
-				v_rom_mac[2], v_rom_mac[3],
-				v_rom_mac[4], v_rom_mac[5] );
-			printf ("\t\"ethaddr\" value: "
-				"%02X:%02X:%02X:%02X:%02X:%02X\n",
-				v_env_mac[0], v_env_mac[1],
-				v_env_mac[2], v_env_mac[3],
-				v_env_mac[4], v_env_mac[5]) ;
-			debug ("### Set MAC addr from environment\n");
-		}
-	}
-	memcpy (bd->bi_enetaddr, v_mac, 6);	/* update global address to match env (allows env changing) */
-	smc_set_mac_addr ((unsigned char *)v_mac); /* use old function to update smc default */
-	PRINTK("Using MAC Address %02X:%02X:%02X:%02X:%02X:%02X\n", v_mac[0], v_mac[1],
-		v_mac[2], v_mac[3], v_mac[4], v_mac[5]);
-	return (0);
+	smc_set_mac_addr(v_mac); /* use old function to update smc default */
+	str_enetaddr(buf, v_mac);
+	PRINTK("Using MAC Address %s\n", buf);
+	return 0;
 }
 
 /*
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 82abb02..f6d3797 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -834,10 +834,8 @@ static int smc_open (bd_t * bd)
 	SMC_SELECT_BANK (1);
 
 	err = smc_get_ethaddr (bd);	/* set smc_mac_addr, and sync it with u-boot globals */
-	if (err < 0) {
-		memset (bd->bi_enetaddr, 0, 6); /* hack to make error stick! upper code will abort if not set */
-		return (-1);	/* upper code ignores this, but NOT bi_enetaddr */
-	}
+	if (err < 0)
+		return -1;
 #ifdef USE_32_BIT
 	for (i = 0; i < 6; i += 2) {
 		word address;
@@ -1535,66 +1533,22 @@ int eth_send(volatile void *packet, int length) {
 
 int smc_get_ethaddr (bd_t * bd)
 {
-	int env_size, rom_valid, env_present = 0, reg;
-	char *s = NULL, *e, es[] = "11:22:33:44:55:66";
-	char s_env_mac[64];
-	uchar v_env_mac[6], v_rom_mac[6], *v_mac;
-
-	env_size = getenv_r ("ethaddr", s_env_mac, sizeof (s_env_mac));
-	if ((env_size > 0) && (env_size < sizeof (es))) {	/* exit if env is bad */
-		printf ("\n*** ERROR: ethaddr is not set properly!!\n");
-		return (-1);
-	}
-
-	if (env_size > 0) {
-		env_present = 1;
-		s = s_env_mac;
-	}
-
-	for (reg = 0; reg < 6; ++reg) { /* turn string into mac value */
-		v_env_mac[reg] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-
-	rom_valid = get_rom_mac (v_rom_mac);	/* get ROM mac value if any */
-
-	if (!env_present) {	/* if NO env */
-		if (rom_valid) {	/* but ROM is valid */
-			v_mac = v_rom_mac;
-			sprintf (s_env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
-				 v_mac[0], v_mac[1], v_mac[2], v_mac[3],
-				 v_mac[4], v_mac[5]);
-			setenv ("ethaddr", s_env_mac);
-		} else {	/* no env, bad ROM */
-			printf ("\n*** ERROR: ethaddr is NOT set !!\n");
-			return (-1);
+	uchar v_mac[6];
+	char buf[20];
+
+	if (!eth_getenv_enetaddr("ethaddr", v_mac)) {
+		/* get ROM mac value if any */
+		if (!get_rom_mac(v_mac)) {
+			printf("\n*** ERROR: ethaddr is NOT set !!\n");
+			return -1;
 		}
-	} else {		/* good env, don't care ROM */
-		v_mac = v_env_mac;	/* always use a good env over a ROM */
+		eth_setenv_enetaddr("ethaddr", v_mac);
 	}
 
-	if (env_present && rom_valid) { /* if both env and ROM are good */
-		if (memcmp (v_env_mac, v_rom_mac, 6) != 0) {
-			printf ("\nWarning: MAC addresses don't match:\n");
-			printf ("\tHW MAC address:  "
-				"%02X:%02X:%02X:%02X:%02X:%02X\n",
-				v_rom_mac[0], v_rom_mac[1],
-				v_rom_mac[2], v_rom_mac[3],
-				v_rom_mac[4], v_rom_mac[5] );
-			printf ("\t\"ethaddr\" value: "
-				"%02X:%02X:%02X:%02X:%02X:%02X\n",
-				v_env_mac[0], v_env_mac[1],
-				v_env_mac[2], v_env_mac[3],
-				v_env_mac[4], v_env_mac[5]) ;
-			debug ("### Set MAC addr from environment\n");
-		}
-	}
-	memcpy (bd->bi_enetaddr, v_mac, 6);	/* update global address to match env (allows env changing) */
-	smc_set_mac_addr ((uchar *)v_mac);	/* use old function to update smc default */
-	PRINTK("Using MAC Address %02X:%02X:%02X:%02X:%02X:%02X\n", v_mac[0], v_mac[1],
-		v_mac[2], v_mac[3], v_mac[4], v_mac[5]);
-	return (0);
+	smc_set_mac_addr(v_mac); /* use old function to update smc default */
+	str_enetaddr(buf, v_mac);
+	PRINTK("Using MAC Address %s\n", buf);
+	return 0;
 }
 
 int get_rom_mac (uchar *v_rom_mac)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 9cc4fce..a737766 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -434,15 +434,11 @@ void smc911x_set_mac_csr(u8 reg, u32 data)
 static int smx911x_handle_mac_address(bd_t *bd)
 {
 	unsigned long addrh, addrl;
-	unsigned char *m = bd->bi_enetaddr;
+	uchar m[6];
+	char buf[20];
 
 	/* if the environment has a valid mac address then use it */
-	if ((m[0] | m[1] | m[2] | m[3] | m[4] | m[5])) {
-		addrl = m[0] | m[1] << 8 | m[2] << 16 | m[3] << 24;
-		addrh = m[4] | m[5] << 8;
-		smc911x_set_mac_csr(ADDRH, addrh);
-		smc911x_set_mac_csr(ADDRL, addrl);
-	} else {
+	if (!eth_getenv_enetaddr("ethaddr", m))
 		/* if not, try to get one from the eeprom */
 		addrh = smc911x_get_mac_csr(ADDRH);
 		addrl = smc911x_get_mac_csr(ADDRL);
@@ -460,10 +456,11 @@ static int smx911x_handle_mac_address(bd_t *bd)
 				"and no eeprom found\n");
 			return -1;
 		}
+
+		eth_setenv_enetaddr("ethaddr", m);
 	}
 
-	printf(DRIVERNAME ": MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
-		m[0], m[1], m[2], m[3], m[4], m[5]);
+	printf(DRIVERNAME ": MAC %s\n", str_enetaddr(buf, m));
 
 	return 0;
 }
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 16/27] cpu/: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (14 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 15/27] lan91c96/smc91111/smc911x: " Mike Frysinger
@ 2009-02-14  7:22 ` Mike Frysinger
  2009-02-16 22:52   ` Wolfgang Denk
  2009-02-14  7:23 ` [U-Boot] [PATCH 17/27] npe: " Mike Frysinger
                   ` (10 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:22 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The cpus that get converted here:
	at91rm9200
	mpc512x
	mpc5xxx
	mpc8260
	mpc8xx
	ppc4xx

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: John Rigby <jrigby@freescale.com>
CC: Stefan Roese <sr@denx.de>
---
 cpu/arm920t/at91rm9200/ether.c |    8 +++++---
 cpu/mpc512x/cpu.c              |    6 ++++--
 cpu/mpc5xxx/cpu.c              |    6 ++++--
 cpu/mpc8260/ether_fcc.c        |    4 ++--
 cpu/mpc8260/ether_scc.c        |    4 ++--
 cpu/ppc4xx/cpu_init.c          |   14 ++++++++------
 post/cpu/mpc8xx/ether.c        |    4 ++--
 7 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/cpu/arm920t/at91rm9200/ether.c b/cpu/arm920t/at91rm9200/ether.c
index f20e070..b00b948 100644
--- a/cpu/arm920t/at91rm9200/ether.c
+++ b/cpu/arm920t/at91rm9200/ether.c
@@ -155,6 +155,7 @@ int eth_init (bd_t * bd)
 {
 	int ret;
 	int i;
+	uchar enetaddr[6];
 
 	p_mac = AT91C_BASE_EMAC;
 
@@ -190,9 +191,10 @@ int eth_init (bd_t * bd)
 	rbfdt[RBF_FRAMEMAX - 1].addr |= RBF_WRAP;
 	rbfp = &rbfdt[0];
 
-	p_mac->EMAC_SA2L = (bd->bi_enetaddr[3] << 24) | (bd->bi_enetaddr[2] << 16)
-			 | (bd->bi_enetaddr[1] <<  8) | (bd->bi_enetaddr[0]);
-	p_mac->EMAC_SA2H = (bd->bi_enetaddr[5] <<  8) | (bd->bi_enetaddr[4]);
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	p_mac->EMAC_SA2L = (enetaddr[3] << 24) | (enetaddr[2] << 16)
+			 | (enetaddr[1] <<  8) | (enetaddr[0]);
+	p_mac->EMAC_SA2H = (enetaddr[5] <<  8) | (enetaddr[4]);
 
 	p_mac->EMAC_RBQP = (long) (&rbfdt[0]);
 	p_mac->EMAC_RSR &= ~(AT91C_EMAC_RSR_OVR | AT91C_EMAC_REC | AT91C_EMAC_BNA);
diff --git a/cpu/mpc512x/cpu.c b/cpu/mpc512x/cpu.c
index b9069b0..be532af 100644
--- a/cpu/mpc512x/cpu.c
+++ b/cpu/mpc512x/cpu.c
@@ -148,15 +148,17 @@ static void old_ft_cpu_setup(void *blob, bd_t *bd)
 	 * avoid fixing up by path because that
 	 * produces scary error messages
 	 */
+	uchar enetaddr[6];
 
 	/*
 	 * old device trees have ethernet nodes with
 	 * device_type = "network"
 	 */
+	eth_getenv_enetaddr("ethaddr", enetaddr);
 	do_fixup_by_prop(blob, "device_type", "network", 8,
-		"local-mac-address", bd->bi_enetaddr, 6, 0);
+		"local-mac-address", enetaddr, 6, 0);
 	do_fixup_by_prop(blob, "device_type", "network", 8,
-		"address", bd->bi_enetaddr, 6, 0);
+		"address", enetaddr, 6, 0);
 	/*
 	 * old device trees have soc nodes with
 	 * device_type = "soc"
diff --git a/cpu/mpc5xxx/cpu.c b/cpu/mpc5xxx/cpu.c
index 9c6ab76..ad5ef8e 100644
--- a/cpu/mpc5xxx/cpu.c
+++ b/cpu/mpc5xxx/cpu.c
@@ -121,6 +121,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 	int div = in_8((void*)CONFIG_SYS_MBAR + 0x204) & 0x0020 ? 8 : 4;
 	char * cpu_path = "/cpus/" OF_CPU;
 #ifdef CONFIG_MPC5xxx_FEC
+	uchar *enetaddr[6];
 	char * eth_path = "/" OF_SOC "/ethernet at 3000";
 #endif
 
@@ -131,8 +132,9 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 	do_fixup_by_path_u32(blob, "/" OF_SOC, "system-frequency",
 				bd->bi_busfreq*div, 1);
 #ifdef CONFIG_MPC5xxx_FEC
-	do_fixup_by_path(blob, eth_path, "mac-address", bd->bi_enetaddr, 6, 0);
-	do_fixup_by_path(blob, eth_path, "local-mac-address", bd->bi_enetaddr, 6, 0);
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	do_fixup_by_path(blob, eth_path, "mac-address", enetaddr, 6, 0);
+	do_fixup_by_path(blob, eth_path, "local-mac-address", enetaddr, 6, 0);
 #endif
 }
 #endif
diff --git a/cpu/mpc8260/ether_fcc.c b/cpu/mpc8260/ether_fcc.c
index 3ab57eb..5ac02a0 100644
--- a/cpu/mpc8260/ether_fcc.c
+++ b/cpu/mpc8260/ether_fcc.c
@@ -654,7 +654,7 @@ eth_loopback_test (void)
 
 	puts ("FCC Ethernet External loopback test\n");
 
-	memcpy (NetOurEther, gd->bd->bi_enetaddr, 6);
+	eth_getenv_enetaddr("ethaddr", NetOurEther);
 
 	/*
 	 * global initialisations for all FCC channels
@@ -841,7 +841,7 @@ eth_loopback_test (void)
 		 * So, far we have only been given one Ethernet address. We use
 		 * the same address for all channels
 		 */
-#define ea gd->bd->bi_enetaddr
+#define ea NetOurEther
 		fpp->fen_paddrh = (ea[5] << 8) + ea[4];
 		fpp->fen_paddrm = (ea[3] << 8) + ea[2];
 		fpp->fen_paddrl = (ea[1] << 8) + ea[0];
diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c
index 3671ef1..123d512 100644
--- a/cpu/mpc8260/ether_scc.c
+++ b/cpu/mpc8260/ether_scc.c
@@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t *bis)
     volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     scc_enet_t *pram_ptr;
     uint dpaddr;
+	uchar ea[6];
 
     rxIdx = 0;
     txIdx = 0;
@@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t *bis)
     pram_ptr->sen_gaddr3 = 0x0;   /* Group Address Filter 3 (unused) */
     pram_ptr->sen_gaddr4 = 0x0;   /* Group Address Filter 4 (unused) */
 
-#  define ea bis->bi_enetaddr
+	eth_getenv_enetaddr("ethaddr", ea);
     pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
     pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
     pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
-#  undef ea
 
     pram_ptr->sen_pper   = 0x0;   /* Persistence (unused) */
 
diff --git a/cpu/ppc4xx/cpu_init.c b/cpu/ppc4xx/cpu_init.c
index b5d81f2..a8f589a 100644
--- a/cpu/ppc4xx/cpu_init.c
+++ b/cpu/ppc4xx/cpu_init.c
@@ -324,6 +324,7 @@ int cpu_init_r (void)
 #if defined(CONFIG_405GP)  || defined(CONFIG_405EP)
 	bd_t *bd = gd->bd;
 	unsigned long reg;
+	uchar enetaddr[6];
 #if defined(CONFIG_405GP)
 	uint pvr = get_pvr();
 #endif
@@ -332,19 +333,20 @@ int cpu_init_r (void)
 	 * Write Ethernetaddress into on-chip register
 	 */
 	reg = 0x00000000;
-	reg |= bd->bi_enetaddr[0];           /* set high address */
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	reg |= enetaddr[0];           /* set high address */
 	reg = reg << 8;
-	reg |= bd->bi_enetaddr[1];
+	reg |= enetaddr[1];
 	out32 (EMAC_IAH, reg);
 
 	reg = 0x00000000;
-	reg |= bd->bi_enetaddr[2];           /* set low address  */
+	reg |= enetaddr[2];           /* set low address  */
 	reg = reg << 8;
-	reg |= bd->bi_enetaddr[3];
+	reg |= enetaddr[3];
 	reg = reg << 8;
-	reg |= bd->bi_enetaddr[4];
+	reg |= enetaddr[4];
 	reg = reg << 8;
-	reg |= bd->bi_enetaddr[5];
+	reg |= enetaddr[5];
 	out32 (EMAC_IAL, reg);
 
 #if defined(CONFIG_405GP)
diff --git a/post/cpu/mpc8xx/ether.c b/post/cpu/mpc8xx/ether.c
index 5622cb7..fe6c39e 100644
--- a/post/cpu/mpc8xx/ether.c
+++ b/post/cpu/mpc8xx/ether.c
@@ -110,6 +110,7 @@ static RTXBD *rtx;
 static void scc_init (int scc_index)
 {
 	bd_t *bd = gd->bd;
+	uchar ea[6];
 
 	static int proff[] =
 			{ PROFF_SCC1, PROFF_SCC2, PROFF_SCC3, PROFF_SCC4 };
@@ -296,11 +297,10 @@ CPM_CR_CH_SCC4 };
 	pram_ptr->sen_gaddr3 = 0x0;	/* Group Address Filter 3 (unused) */
 	pram_ptr->sen_gaddr4 = 0x0;	/* Group Address Filter 4 (unused) */
 
-#define ea bd->bi_enetaddr
+	eth_getenv_enetaddr("ethaddr", ea);
 	pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
 	pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
 	pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
-#undef ea
 
 	pram_ptr->sen_pper = 0x0;	/* Persistence (unused) */
 	pram_ptr->sen_iaddr1 = 0x0;	/* Individual Address Filter 1 (unused) */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 17/27] npe: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (15 preceding siblings ...)
  2009-02-14  7:22 ` [U-Boot] [PATCH 16/27] cpu/: " Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-14  7:23 ` [U-Boot] [PATCH 18/27] lib_*/board.c: do not initialize bi_enet*addr in global data Mike Frysinger
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The resulting code can also be simplified even further.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Stefan Roese <sr@denx.de>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 cpu/ixp/npe/npe.c |   36 +++++++++++-------------------------
 1 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/cpu/ixp/npe/npe.c b/cpu/ixp/npe/npe.c
index 03e3bf7..2e68689 100644
--- a/cpu/ixp/npe/npe.c
+++ b/cpu/ixp/npe/npe.c
@@ -565,25 +565,19 @@ int npe_initialize(bd_t * bis)
 	struct eth_device *dev;
 	int eth_num = 0;
 	struct npe *p_npe = NULL;
+	uchar enetaddr[6];
 
 	for (eth_num = 0; eth_num < CONFIG_SYS_NPE_NUMS; eth_num++) {
 
 		/* See if we can actually bring up the interface, otherwise, skip it */
-		switch (eth_num) {
-		default:		/* fall through */
-		case 0:
-			if (memcmp (bis->bi_enetaddr, "\0\0\0\0\0\0", 6) == 0) {
-				continue;
-			}
-			break;
 #ifdef CONFIG_HAS_ETH1
-		case 1:
-			if (memcmp (bis->bi_enet1addr, "\0\0\0\0\0\0", 6) == 0) {
+		if (eth_num == 1) {
+			if (!eth_getenv_enetaddr("eth1addr", enetaddr))
 				continue;
-			}
-			break;
+		} else
 #endif
-		}
+			if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+				continue;
 
 		/* Allocate device structure */
 		dev = (struct eth_device *)malloc(sizeof(*dev));
@@ -603,22 +597,14 @@ int npe_initialize(bd_t * bis)
 		}
 		memset(p_npe, 0, sizeof(struct npe));
 
-		switch (eth_num) {
-		default:		/* fall through */
-		case 0:
-			memcpy(dev->enetaddr, bis->bi_enetaddr, 6);
-			p_npe->eth_id = 0;
-			p_npe->phy_no = CONFIG_PHY_ADDR;
-			break;
-
+		p_npe->eth_id = eth_num;
+		memcpy(dev->enetaddr, enetaddr, 6);
 #ifdef CONFIG_HAS_ETH1
-		case 1:
-			memcpy(dev->enetaddr, bis->bi_enet1addr, 6);
-			p_npe->eth_id = 1;
+		if (eth_num == 1)
 			p_npe->phy_no = CONFIG_PHY1_ADDR;
-			break;
+		else
 #endif
-		}
+			p_npe->phy_no = CONFIG_PHY_ADDR;
 
 		sprintf(dev->name, "NPE%d", eth_num);
 		dev->priv = (void *)p_npe;
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 18/27] lib_*/board.c: do not initialize bi_enet*addr in global data
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (16 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 17/27] npe: " Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-14  7:23 ` [U-Boot] [PATCH 19/27] nx823: get mac address from environment Mike Frysinger
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

Since everyone is using the environment for mac address storage, there is
no point in seeding the global data.

The arches that are converted here:
	i386
	m68k
	microblaze
	mips
	nios
	nios2
	sh
	sparc

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Daniel Hellstrom <daniel@gaisler.com>
CC: Michal Simek <monstr@seznam.cz>
CC: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
CC: Scott McNutt <smcnutt@psyent.com>
CC: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 lib_i386/board.c       |   17 -----------------
 lib_m68k/board.c       |   38 --------------------------------------
 lib_microblaze/board.c |    8 --------
 lib_mips/board.c       |    8 --------
 lib_nios/board.c       |    5 -----
 lib_nios2/board.c      |    5 -----
 lib_sh/board.c         |   10 ----------
 lib_sparc/board.c      |   19 -------------------
 8 files changed, 0 insertions(+), 110 deletions(-)

diff --git a/lib_i386/board.c b/lib_i386/board.c
index 1734f86..29683ee 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -262,23 +262,6 @@ void start_i386boot (void)
 	/* IP Address */
 	bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr");
 
-	/* MAC Address */
-	{
-		int i;
-		ulong reg;
-		char *s, *e;
-		char tmp[64];
-
-		i = getenv_r ("ethaddr", tmp, sizeof (tmp));
-		s = (i > 0) ? tmp : NULL;
-
-		for (reg = 0; reg < 6; ++reg) {
-			bd_data.bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
-		}
-	}
-
 #if defined(CONFIG_PCI)
 	/*
 	 * Do pci configuration
diff --git a/lib_m68k/board.c b/lib_m68k/board.c
index 583ce10..db45b00 100644
--- a/lib_m68k/board.c
+++ b/lib_m68k/board.c
@@ -584,44 +584,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	 * where had to use getenv_r(), which can be pretty slow when
 	 * the environment is in EEPROM.
 	 */
-	s = getenv ("ethaddr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#ifdef CONFIG_HAS_ETH1
-	/* handle the 2nd ethernet address */
-
-	s = getenv ("eth1addr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-#ifdef CONFIG_HAS_ETH2
-	/* handle the 3rd ethernet address */
-
-	s = getenv ("eth2addr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
-#ifdef CONFIG_HAS_ETH3
-	/* handle 4th ethernet address */
-	s = getenv("eth3addr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
-	/* IP Address */
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
 
 	WATCHDOG_RESET ();
diff --git a/lib_microblaze/board.c b/lib_microblaze/board.c
index 30d7641..1a42640 100644
--- a/lib_microblaze/board.c
+++ b/lib_microblaze/board.c
@@ -173,14 +173,6 @@ void board_init (void)
 #endif
 
 #if defined(CONFIG_CMD_NET)
-	/* board MAC address */
-	s = getenv ("ethaddr");
-	printf ("MAC:%s\n",s);
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
 	/* IP Address */
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
 	eth_init (bd);
diff --git a/lib_mips/board.c b/lib_mips/board.c
index dfe6831..6fc4845 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -401,14 +401,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
-	/* board MAC address */
-	s = getenv ("ethaddr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-
 	/* IP Address */
 	bd->bi_ip_addr = getenv_IPaddr("ipaddr");
 
diff --git a/lib_nios/board.c b/lib_nios/board.c
index 024beb5..63e79ae 100644
--- a/lib_nios/board.c
+++ b/lib_nios/board.c
@@ -151,11 +151,6 @@ void board_init (void)
 	env_relocate();
 
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-	s = getenv ("ethaddr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s) s = (*e) ? e + 1 : e;
-	}
 
 	WATCHDOG_RESET ();
 	devices_init();
diff --git a/lib_nios2/board.c b/lib_nios2/board.c
index d759f0f..70fad1b 100644
--- a/lib_nios2/board.c
+++ b/lib_nios2/board.c
@@ -157,11 +157,6 @@ void board_init (void)
 	env_relocate();
 
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-	s = getenv ("ethaddr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s) s = (*e) ? e + 1 : e;
-	}
 
 	WATCHDOG_RESET ();
 	devices_init();
diff --git a/lib_sh/board.c b/lib_sh/board.c
index d4cc85c..2fd213b 100644
--- a/lib_sh/board.c
+++ b/lib_sh/board.c
@@ -125,17 +125,7 @@ static int sh_mem_env_init(void)
 static int sh_net_init(void)
 {
 	DECLARE_GLOBAL_DATA_PTR;
-	char *s, *e;
-	int i;
-
 	gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-	s = getenv("ethaddr");
-	for (i = 0; i < 6; ++i) {
-		gd->bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-
 	return 0;
 }
 #endif
diff --git a/lib_sparc/board.c b/lib_sparc/board.c
index e972d3e..2f3e673 100644
--- a/lib_sparc/board.c
+++ b/lib_sparc/board.c
@@ -390,25 +390,6 @@ void board_init_f(ulong bootflag)
 	board_late_init();
 #endif
 
-	s = getenv("ethaddr");
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-
-#ifdef CONFIG_HAS_ETH1
-	/* handle the 2nd ethernet address */
-
-	s = getenv("eth1addr");
-
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet1addr[i] = s ? simple_strtoul(s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
 #ifdef CONFIG_ID_EEPROM
 	mac_read_from_eeprom();
 #endif
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 19/27] nx823: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (17 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 18/27] lib_*/board.c: do not initialize bi_enet*addr in global data Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-14  7:23 ` [U-Boot] [PATCH 20/27] arm: " Mike Frysinger
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

For the nx823, the serial number is moved out of load_sernum_ethaddr() and
into misc_init_r() as is the env setup.  This lets us kill off the former
function in the process.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/nx823/flash.c |    5 +++--
 board/nx823/nx823.c |   41 ++++++++++++++++-------------------------
 lib_ppc/board.c     |    4 ----
 3 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/board/nx823/flash.c b/board/nx823/flash.c
index 194d841..336e704 100644
--- a/board/nx823/flash.c
+++ b/board/nx823/flash.c
@@ -27,8 +27,9 @@
 #include <common.h>
 #include <mpc8xx.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 flash_info_t	flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips	*/
-extern u_long  *my_sernum;		/* from nx823.c */
 
 /*-----------------------------------------------------------------------
  * Protection Flags:
@@ -346,7 +347,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 	if (addr >= CONFIG_SYS_FLASH_SN_SECTOR && addr < CONFIG_SYS_FLASH_SN_BASE)
 	{
 		u_long dest = CONFIG_SYS_FLASH_SN_BASE;
-		u_short *sn = (u_short *)my_sernum;
+		u_short *sn = (u_short *)gd->bd->bi_sernum;
 
 		printf("(saving sernum)");
 		for (i=0; i<4; i++)
diff --git a/board/nx823/nx823.c b/board/nx823/nx823.c
index df9aaab..6ec29dc 100644
--- a/board/nx823/nx823.c
+++ b/board/nx823/nx823.c
@@ -360,39 +360,30 @@ static long int dram_size (long int mamr_value, long int *base,
 	return (get_ram_size (base, maxsize));
 }
 
-u_long *my_sernum;
-
 int misc_init_r (void)
 {
+	int i;
 	char tmp[50];
-	u_char *e = gd->bd->bi_enetaddr;
+	uchar ethaddr[6];
+	bd_t *bd = gd->bd;
+	ulong my_sernum = bd->bi_sernum;
 
-	/* save serial numbre from flash (uniquely programmed) */
-	my_sernum = malloc (8);
-	memcpy (my_sernum, gd->bd->bi_sernum, 8);
+	/* load unique serial number */
+	for (i = 0; i < 8; ++i)
+		bd->bi_sernum[i] = *(u_char *) (CONFIG_SYS_FLASH_SN_BASE + i);
 
 	/* save env variables according to sernum */
 	sprintf (tmp, "%08lx%08lx", my_sernum[0], my_sernum[1]);
 	setenv ("serial#", tmp);
 
-	sprintf (tmp, "%02x:%02x:%02x:%02x:%02x:%02x", e[0], e[1], e[2], e[3],
-		 e[4], e[5]);
-	setenv ("ethaddr", tmp);
-	return (0);
-}
-
-void load_sernum_ethaddr (void)
-{
-	int i;
-	bd_t *bd = gd->bd;
-
-	for (i = 0; i < 8; i++) {
-		bd->bi_sernum[i] = *(u_char *) (CONFIG_SYS_FLASH_SN_BASE + i);
+	if (!eth_getenv_enetaddr("ethaddr", ethaddr)) {
+		ethaddr[0] = 0x10;
+		ethaddr[1] = 0x20;
+		ethaddr[2] = 0x30;
+		ethaddr[3] = bd->bi_sernum[1] << 4 | bd->bi_sernum[2];
+		ethaddr[4] = bd->bi_sernum[5];
+		ethaddr[5] = bd->bi_sernum[6];
 	}
-	bd->bi_enetaddr[0] = 0x10;
-	bd->bi_enetaddr[1] = 0x20;
-	bd->bi_enetaddr[2] = 0x30;
-	bd->bi_enetaddr[3] = bd->bi_sernum[1] << 4 | bd->bi_sernum[2];
-	bd->bi_enetaddr[4] = bd->bi_sernum[5];
-	bd->bi_enetaddr[5] = bd->bi_sernum[6];
+
+	return 0;
 }
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index d90607d..1235514 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -900,10 +900,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 		bd->bi_ethspeed = 0xFFFF;
 #endif
 
-#ifdef CONFIG_NX823
-	load_sernum_ethaddr ();
-#endif
-
 #ifdef CONFIG_HAS_ETH1
 	/* handle the 2nd ethernet address */
 
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 20/27] arm: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (18 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 19/27] nx823: get mac address from environment Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-14  7:23 ` [U-Boot] [PATCH 21/27] cmc_pu2: " Mike Frysinger
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Some warts are remaining and should be killed off (by moving the func to
the appropriate board init code):
	- davinci_eth_set_mac_addr
	- cs8900_get_enetaddr
	- smc_set_mac_addr

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 lib_arm/board.c |   43 +++++++++++--------------------------------
 1 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/lib_arm/board.c b/lib_arm/board.c
index 964f5cc..8fe2f41 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -73,7 +73,7 @@ const char version_string[] =
 	U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")"CONFIG_IDENT_STRING;
 
 #ifdef CONFIG_DRIVER_CS8900
-extern void cs8900_get_enetaddr (uchar * addr);
+extern void cs8900_get_enetaddr (void);
 #endif
 
 #ifdef CONFIG_DRIVER_RTL8019
@@ -380,34 +380,6 @@ void start_armboot (void)
 	/* IP Address */
 	gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
 
-	/* MAC Address */
-	{
-		int i;
-		ulong reg;
-		char *s, *e;
-		char tmp[64];
-
-		i = getenv_r ("ethaddr", tmp, sizeof (tmp));
-		s = (i > 0) ? tmp : NULL;
-
-		for (reg = 0; reg < 6; ++reg) {
-			gd->bd->bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
-		}
-
-#ifdef CONFIG_HAS_ETH1
-		i = getenv_r ("eth1addr", tmp, sizeof (tmp));
-		s = (i > 0) ? tmp : NULL;
-
-		for (reg = 0; reg < 6; ++reg) {
-			gd->bd->bi_enet1addr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
-		}
-#endif
-	}
-
 	devices_init ();	/* get the devices list going. */
 
 #ifdef CONFIG_CMC_PU2
@@ -428,19 +400,26 @@ void start_armboot (void)
 
 	/* Perform network card initialisation if necessary */
 #ifdef CONFIG_DRIVER_TI_EMAC
+	/* XXX: this needs to be moved to board init */
 extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
 	if (getenv ("ethaddr")) {
-		davinci_eth_set_mac_addr(gd->bd->bi_enetaddr);
+		uchar enetaddr[6];
+		eth_getenv_enetaddr("ethaddr", enetaddr);
+		davinci_eth_set_mac_addr(enetaddr);
 	}
 #endif
 
 #ifdef CONFIG_DRIVER_CS8900
-	cs8900_get_enetaddr (gd->bd->bi_enetaddr);
+	/* XXX: this needs to be moved to board init */
+	cs8900_get_enetaddr ();
 #endif
 
 #if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
+	/* XXX: this needs to be moved to board init */
 	if (getenv ("ethaddr")) {
-		smc_set_mac_addr(gd->bd->bi_enetaddr);
+		uchar enetaddr[6];
+		eth_getenv_enetaddr("ethaddr", enetaddr);
+		smc_set_mac_addr(enetaddr);
 	}
 #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
 
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 21/27] cmc_pu2: get mac address from environment
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (19 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 20/27] arm: " Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-16 22:56   ` Wolfgang Denk
  2009-02-14  7:23 ` [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init Mike Frysinger
                   ` (5 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Also rename load_sernum_ethaddr() to misc_init_r() so we don't need to
handle this board specially in common ARM code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/cmc_pu2/load_sernum_ethaddr.c |   18 +++---------------
 include/configs/cmc_pu2.h           |    1 +
 lib_arm/board.c                     |    4 ----
 3 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/board/cmc_pu2/load_sernum_ethaddr.c b/board/cmc_pu2/load_sernum_ethaddr.c
index 354566c..5ef9f20 100644
--- a/board/cmc_pu2/load_sernum_ethaddr.c
+++ b/board/cmc_pu2/load_sernum_ethaddr.c
@@ -66,14 +66,13 @@ int i2c_read (unsigned char chip, unsigned int addr, int alen,
  * Internal structure: see struct definition
  */
 
-void load_sernum_ethaddr (void)
+void misc_init_r(void)
 {
 	struct manufacturer_data data;
-	char  ethaddr[18];
 	char  serial [9];
 	unsigned short chksum;
 	unsigned char *p;
-	unsigned short i, is, id;
+	unsigned short i;
 
 #if !defined(CONFIG_HARD_I2C) && !defined(CONFIG_SOFT_I2C)
 #error you must define some I2C support (CONFIG_HARD_I2C or CONFIG_SOFT_I2C)
@@ -97,17 +96,6 @@ void load_sernum_ethaddr (void)
 		return;
 	}
 
-	/* copy MAC address */
-	is = 0;
-	id = 0;
-	for (i = 0; i < 6; i++) {
-		sprintf (&ethaddr[id], "%02x", data.macadr[is++]);
-		id += 2;
-		if (is < 6)
-			ethaddr[id++] = ':';
-	}
-	ethaddr[id] = '\0';	/* just to be sure */
-
 	/* copy serial number */
 	sprintf (serial, "%d", data.serial_number);
 
@@ -117,6 +105,6 @@ void load_sernum_ethaddr (void)
 	}
 
 	if (getenv("ethaddr") == NULL) {
-		setenv ("ethaddr", ethaddr);
+		eth_setenv_enetaddr("ethaddr", data.macadr);
 	}
 }
diff --git a/include/configs/cmc_pu2.h b/include/configs/cmc_pu2.h
index d9acb47..e5c74e1 100644
--- a/include/configs/cmc_pu2.h
+++ b/include/configs/cmc_pu2.h
@@ -143,6 +143,7 @@
 #endif
 
 
+#define CONFIG_MISC_INIT_R
 #define CONFIG_SYS_LONGHELP
 
 #define AT91_SMART_MEDIA_ALE	(1 << 22)	/* our ALE is AD22 */
diff --git a/lib_arm/board.c b/lib_arm/board.c
index 8fe2f41..7199f52 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -382,10 +382,6 @@ void start_armboot (void)
 
 	devices_init ();	/* get the devices list going. */
 
-#ifdef CONFIG_CMC_PU2
-	load_sernum_ethaddr ();
-#endif /* CONFIG_CMC_PU2 */
-
 	jumptable_init ();
 
 	console_init_r ();	/* fully init console as a device */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (20 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 21/27] cmc_pu2: " Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-16 22:57   ` Wolfgang Denk
  2009-02-14  7:23 ` [U-Boot] [PATCH 23/27] kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr() Mike Frysinger
                   ` (4 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Move all the work of load_sernum_ethaddr() into a local load_ethaddr()
func and call that from misc_init_r().  We leave load_sernum_ethaddr()
as a stub so that it can be removed from all places in a later commit.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Stefan Roese <sr@denx.de>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/pcs440ep/pcs440ep.c |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c
index 5fd3291..067d959 100644
--- a/board/pcs440ep/pcs440ep.c
+++ b/board/pcs440ep/pcs440ep.c
@@ -182,14 +182,21 @@ int board_early_init_f(void)
 }
 
 #define EEPROM_LEN	256
-void load_sernum_ethaddr (void)
+static void load_ethaddr(void)
 {
+	int	ok_ethaddr, ok_eth1addr;
 	int	ret;
 	char	buf[EEPROM_LEN];
 	char	mac[32];
 	char	*use_eeprom;
 	u16	checksumcrc16 = 0;
 
+	/* If the env is sane, then nothing for us to do */
+	ok_ethaddr = eth_getenv_enetaddr("ethaddr", buf);
+	ok_eth1addr = eth_getenv_enetaddr("eth1addr", buf);
+	if (ok_ethaddr && ok_eth1addr)
+		return;
+
 	/* read the MACs from EEprom */
 	status_led_set (0, STATUS_LED_ON);
 	status_led_set (1, STATUS_LED_ON);
@@ -207,22 +214,10 @@ void load_sernum_ethaddr (void)
 			printf("%s: EEPROM Checksum not OK\n", __FUNCTION__);
 		} else {
 			/* get the MACs */
-			sprintf (mac, "%02x:%02x:%02x:%02x:%02x:%02x",
-				buf[3],
-				buf[4],
-				buf[5],
-				buf[6],
-				buf[7],
-				buf[8]);
-			setenv ("ethaddr", (char *) mac);
-			sprintf (mac, "%02x:%02x:%02x:%02x:%02x:%02x",
-				buf[9],
-				buf[10],
-				buf[11],
-				buf[12],
-				buf[13],
-				buf[14]);
-			setenv ("eth1addr", (char *) mac);
+			if (!ok_ethaddr)
+				eth_setenv_enetaddr("ethaddr", &buf[3]);
+			if (!ok_eth1addr)
+				eth_setenv_enetaddr("eth1addr", &buf[9]);
 			return;
 		}
 	}
@@ -249,6 +244,10 @@ void load_sernum_ethaddr (void)
 	return;
 }
 
+void load_sernum_ethaddr (void)
+{
+}
+
 #ifdef CONFIG_PREBOOT
 
 static uchar kbd_magic_prefix[]		= "key_magic";
@@ -446,6 +445,8 @@ int misc_init_r (void)
 	uint pbcr;
 	int size_val = 0;
 
+	load_ethaddr();
+
 	/* Re-do sizing to get full correct info */
 	mtdcr(ebccfga, pb0cr);
 	pbcr = mfdcr(ebccfgd);
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 23/27] kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr()
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (21 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-16 22:58   ` Wolfgang Denk
  2009-02-14  7:23 ` [U-Boot] [PATCH 24/27] tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() Mike Frysinger
                   ` (3 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

Rename load_sernum_ethaddr() to kup_load_sernum_ethaddr() and have board
init code call it rather than the common ppc board code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/kup/common/load_sernum_ethaddr.c |    6 +++++-
 board/kup/kup4k/kup4k.c                |    3 +++
 board/kup/kup4x/kup4x.c                |    4 +++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/board/kup/common/load_sernum_ethaddr.c b/board/kup/common/load_sernum_ethaddr.c
index 741e9a5..5f725f8 100644
--- a/board/kup/common/load_sernum_ethaddr.c
+++ b/board/kup/common/load_sernum_ethaddr.c
@@ -51,7 +51,7 @@
 #define ETHADDR_TOKEN "ethaddr="
 #define LCD_TOKEN "lcd="
 
-void load_sernum_ethaddr (void)
+void kup_load_sernum_ethaddr (void)
 {
 	unsigned char *hwi;
 	char *var;
@@ -92,3 +92,7 @@ void load_sernum_ethaddr (void)
 		}
 	}
 }
+
+void load_sernum_ethaddr (void)
+{
+}
diff --git a/board/kup/kup4k/kup4k.c b/board/kup/kup4k/kup4k.c
index df3ffb4..f49c85a 100644
--- a/board/kup/kup4k/kup4k.c
+++ b/board/kup/kup4k/kup4k.c
@@ -233,6 +233,8 @@ phys_size_t initdram (int board_type)
 
 /* ------------------------------------------------------------------------- */
 
+extern void kup_load_sernum_ethaddr(void);
+
 int misc_init_r (void)
 {
 #ifdef CONFIG_STATUS_LED
@@ -250,6 +252,7 @@ int misc_init_r (void)
 	immap->im_ioport.iop_papar &= ~0x80;
 	immap->im_ioport.iop_padat |= 0x80;	/* turn it off */
 #endif
+	kup_load_sernum_ethaddr();
 	setenv("hw","4k");
 	poweron_key();
 	return (0);
diff --git a/board/kup/kup4x/kup4x.c b/board/kup/kup4x/kup4x.c
index c5b742d..b5b7595 100644
--- a/board/kup/kup4x/kup4x.c
+++ b/board/kup/kup4x/kup4x.c
@@ -292,10 +292,11 @@ static long int dram_size (long int mamr_value, long int *base,
 }
 #endif
 
+extern void kup_load_sernum_ethaddr(void);
+
 int misc_init_r (void)
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-
 #ifdef CONFIG_IDE_LED
 	/* Configure PA8 as output port */
 	immap->im_ioport.iop_padir |= 0x80;
@@ -306,6 +307,7 @@ int misc_init_r (void)
 #ifdef KUP4X_USB
 	usb_init_kup4x ();
 #endif
+	kup_load_sernum_ethaddr();
 	setenv ("hw", "4x");
 	poweron_key ();
 	return (0);
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 24/27] tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (22 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 23/27] kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr() Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-16 22:58   ` Wolfgang Denk
  2009-02-14  7:23 ` [U-Boot] [PATCH 25/27] ppc: do not initialize bi_enet*addr in global data Mike Frysinger
                   ` (2 subsequent siblings)
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

Rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() and have board
init code call it rather than the common ppc board code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/tqc/tqm8xx/load_sernum_ethaddr.c |    6 +++++-
 board/tqc/tqm8xx/tqm8xx.c              |    3 +++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/board/tqc/tqm8xx/load_sernum_ethaddr.c b/board/tqc/tqm8xx/load_sernum_ethaddr.c
index d269902..ea534f7 100644
--- a/board/tqc/tqm8xx/load_sernum_ethaddr.c
+++ b/board/tqc/tqm8xx/load_sernum_ethaddr.c
@@ -49,7 +49,7 @@
  * 4) Number of additional MAC addresses
  */
 
-void load_sernum_ethaddr (void)
+void tqc_load_sernum_ethaddr (void)
 {
 	unsigned char *hwi;
 	unsigned char  serial [CONFIG_SYS_HWINFO_SIZE];
@@ -103,3 +103,7 @@ void load_sernum_ethaddr (void)
 		setenv ((char *)"ethaddr", (char *)ethaddr);
 	}
 }
+
+void load_sernum_ethaddr (void)
+{
+}
diff --git a/board/tqc/tqm8xx/tqm8xx.c b/board/tqc/tqm8xx/tqm8xx.c
index e065d69..ca91554 100644
--- a/board/tqc/tqm8xx/tqm8xx.c
+++ b/board/tqc/tqm8xx/tqm8xx.c
@@ -449,11 +449,14 @@ int board_early_init_r (void)
 
 
 #ifdef CONFIG_MISC_INIT_R
+extern void tqc_load_sernum_ethaddr(void);
 int misc_init_r (void)
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
 	volatile memctl8xx_t *memctl = &immap->im_memctl;
 
+	tqc_load_sernum_ethaddr();
+
 #ifdef	CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ
 	int scy, trlx, flash_or_timing, clk_diff;
 
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 25/27] ppc: do not initialize bi_enet*addr in global data
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (23 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 24/27] tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-14  7:23 ` [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function Mike Frysinger
  2009-02-14  7:23 ` [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches Mike Frysinger
  26 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Also stop calling load_sernum_ethaddr() since all boards now implement
this as a stub.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 lib_ppc/board.c |   92 -------------------------------------------------------
 1 files changed, 0 insertions(+), 92 deletions(-)

diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 1235514..444e804 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -879,20 +879,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	mac_read_from_eeprom();
 #endif
 
-	s = getenv ("ethaddr");
-#if defined (CONFIG_MBX) || \
-    defined (CONFIG_RPXCLASSIC) || \
-    defined(CONFIG_IAD210) || \
-    defined(CONFIG_V38B)
-	if (s == NULL)
-		board_get_enetaddr (bd->bi_enetaddr);
-	else
-#endif
-		for (i = 0; i < 6; ++i) {
-			bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-			if (s)
-				s = (*e) ? e + 1 : e;
-		}
 #ifdef	CONFIG_HERMES
 	if ((gd->board_type >> 16) == 2)
 		bd->bi_ethspeed = gd->board_type & 0xFFFF;
@@ -900,84 +886,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 		bd->bi_ethspeed = 0xFFFF;
 #endif
 
-#ifdef CONFIG_HAS_ETH1
-	/* handle the 2nd ethernet address */
-
-	s = getenv ("eth1addr");
-
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-#ifdef CONFIG_HAS_ETH2
-	/* handle the 3rd ethernet address */
-
-	s = getenv ("eth2addr");
-#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
-	if (s == NULL)
-		board_get_enetaddr(bd->bi_enet2addr);
-	else
-#endif
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
-#ifdef CONFIG_HAS_ETH3
-	/* handle 4th ethernet address */
-	s = getenv("eth3addr");
-#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
-	if (s == NULL)
-		board_get_enetaddr(bd->bi_enet3addr);
-	else
-#endif
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
-#ifdef CONFIG_HAS_ETH4
-	/* handle 5th ethernet address */
-	s = getenv("eth4addr");
-#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
-	if (s == NULL)
-		board_get_enetaddr(bd->bi_enet4addr);
-	else
-#endif
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet4addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
-#ifdef CONFIG_HAS_ETH5
-	/* handle 6th ethernet address */
-	s = getenv("eth5addr");
-#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
-	if (s == NULL)
-		board_get_enetaddr(bd->bi_enet5addr);
-	else
-#endif
-	for (i = 0; i < 6; ++i) {
-		bd->bi_enet5addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
-		if (s)
-			s = (*e) ? e + 1 : e;
-	}
-#endif
-
-#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
-    defined(CONFIG_TQM8272) || \
-    defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
-    defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP)
-	load_sernum_ethaddr ();
-#endif
 	/* IP Address */
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
 
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (24 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 25/27] ppc: do not initialize bi_enet*addr in global data Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-14  9:22   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-02-16 22:58   ` Wolfgang Denk
  2009-02-14  7:23 ` [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches Mike Frysinger
  26 siblings, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 board/kup/common/load_sernum_ethaddr.c |    4 ----
 board/m501sk/m501sk.c                  |    5 -----
 board/pcs440ep/pcs440ep.c              |    4 ----
 board/tqc/tqm8xx/load_sernum_ethaddr.c |    4 ----
 include/common.h                       |    2 --
 5 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/board/kup/common/load_sernum_ethaddr.c b/board/kup/common/load_sernum_ethaddr.c
index 5f725f8..dc4fbfe 100644
--- a/board/kup/common/load_sernum_ethaddr.c
+++ b/board/kup/common/load_sernum_ethaddr.c
@@ -92,7 +92,3 @@ void kup_load_sernum_ethaddr (void)
 		}
 	}
 }
-
-void load_sernum_ethaddr (void)
-{
-}
diff --git a/board/m501sk/m501sk.c b/board/m501sk/m501sk.c
index 65a8b29..dc5b786 100644
--- a/board/m501sk/m501sk.c
+++ b/board/m501sk/m501sk.c
@@ -105,11 +105,6 @@ uchar m501sk_gpio_clear(M501SK_PIO io)
 	return status;
 }
 
-void load_sernum_ethaddr(void)
-{
-	return;
-}
-
 /*
  * Miscelaneous platform dependent initialisations
  */
diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c
index 067d959..2727214 100644
--- a/board/pcs440ep/pcs440ep.c
+++ b/board/pcs440ep/pcs440ep.c
@@ -244,10 +244,6 @@ static void load_ethaddr(void)
 	return;
 }
 
-void load_sernum_ethaddr (void)
-{
-}
-
 #ifdef CONFIG_PREBOOT
 
 static uchar kbd_magic_prefix[]		= "key_magic";
diff --git a/board/tqc/tqm8xx/load_sernum_ethaddr.c b/board/tqc/tqm8xx/load_sernum_ethaddr.c
index ea534f7..970a952 100644
--- a/board/tqc/tqm8xx/load_sernum_ethaddr.c
+++ b/board/tqc/tqm8xx/load_sernum_ethaddr.c
@@ -103,7 +103,3 @@ void tqc_load_sernum_ethaddr (void)
 		setenv ((char *)"ethaddr", (char *)ethaddr);
 	}
 }
-
-void load_sernum_ethaddr (void)
-{
-}
diff --git a/include/common.h b/include/common.h
index afee188..03e9b35 100644
--- a/include/common.h
+++ b/include/common.h
@@ -370,8 +370,6 @@ void  display_mem_map(void);
 void  perform_soft_reset(void);
 #endif
 
-void	load_sernum_ethaddr (void);
-
 /* $(BOARD)/$(BOARD).c */
 int board_early_init_f (void);
 int board_late_init (void);
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
                   ` (25 preceding siblings ...)
  2009-02-14  7:23 ` [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function Mike Frysinger
@ 2009-02-14  7:23 ` Mike Frysinger
  2009-02-16 18:16   ` Scott Wood
  26 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14  7:23 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Daniel Hellstrom <daniel@gaisler.com>
CC: Michal Simek <monstr@seznam.cz>
CC: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
CC: Scott McNutt <smcnutt@psyent.com>
CC: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 include/asm-arm/u-boot.h        |    5 -----
 include/asm-avr32/u-boot.h      |    1 -
 include/asm-blackfin/u-boot.h   |    1 -
 include/asm-i386/u-boot.h       |    1 -
 include/asm-m68k/u-boot.h       |   13 -------------
 include/asm-microblaze/u-boot.h |    1 -
 include/asm-mips/u-boot.h       |    1 -
 include/asm-nios/u-boot.h       |    1 -
 include/asm-nios2/u-boot.h      |    1 -
 include/asm-ppc/u-boot.h        |   19 -------------------
 include/asm-sh/u-boot.h         |    1 -
 include/asm-sparc/u-boot.h      |   12 ------------
 12 files changed, 0 insertions(+), 57 deletions(-)

diff --git a/include/asm-arm/u-boot.h b/include/asm-arm/u-boot.h
index b11d555..cfd5a9b 100644
--- a/include/asm-arm/u-boot.h
+++ b/include/asm-arm/u-boot.h
@@ -39,7 +39,6 @@
 typedef struct bd_info {
     int			bi_baudrate;	/* serial console baudrate */
     unsigned long	bi_ip_addr;	/* IP Address */
-    unsigned char	bi_enetaddr[6]; /* Ethernet adress */
     struct environment_s	       *bi_env;
     ulong	        bi_arch_number;	/* unique id for this board */
     ulong	        bi_boot_params;	/* where this board expects params */
@@ -48,10 +47,6 @@ typedef struct bd_info {
 	ulong start;
 	ulong size;
     }			bi_dram[CONFIG_NR_DRAM_BANKS];
-#ifdef CONFIG_HAS_ETH1
-    /* second onboard ethernet port */
-    unsigned char   bi_enet1addr[6];
-#endif
 } bd_t;
 
 #define bi_env_data bi_env->data
diff --git a/include/asm-avr32/u-boot.h b/include/asm-avr32/u-boot.h
index 85ef008..7e4001f 100644
--- a/include/asm-avr32/u-boot.h
+++ b/include/asm-avr32/u-boot.h
@@ -25,7 +25,6 @@
 typedef struct bd_info {
 	unsigned long		bi_baudrate;
 	unsigned long		bi_ip_addr;
-	unsigned char		bi_enetaddr[6];
 	unsigned char		bi_phy_id[4];
 	struct environment_s	*bi_env;
 	unsigned long		bi_board_number;
diff --git a/include/asm-blackfin/u-boot.h b/include/asm-blackfin/u-boot.h
index 9d2903b..a6e6cf0 100644
--- a/include/asm-blackfin/u-boot.h
+++ b/include/asm-blackfin/u-boot.h
@@ -31,7 +31,6 @@
 typedef struct bd_info {
 	int bi_baudrate;		/* serial console baudrate */
 	unsigned long bi_ip_addr;	/* IP Address */
-	unsigned char bi_enetaddr[6];	/* Ethernet adress */
 	unsigned long bi_boot_params;	/* where this board expects params */
 	unsigned long bi_memstart;	/* start of DRAM memory */
 	phys_size_t bi_memsize;		/* size  of DRAM memory in bytes */
diff --git a/include/asm-i386/u-boot.h b/include/asm-i386/u-boot.h
index fc5a2ae..9a1eec0 100644
--- a/include/asm-i386/u-boot.h
+++ b/include/asm-i386/u-boot.h
@@ -46,7 +46,6 @@ typedef struct bd_info {
 	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
 	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
 	unsigned long	bi_ip_addr;	/* IP Address */
-	unsigned char	bi_enetaddr[6];	/* Ethernet adress */
 	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
 	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
 	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
diff --git a/include/asm-m68k/u-boot.h b/include/asm-m68k/u-boot.h
index 5a0d5fe..a0f2983 100644
--- a/include/asm-m68k/u-boot.h
+++ b/include/asm-m68k/u-boot.h
@@ -48,7 +48,6 @@ typedef struct bd_info {
 	unsigned long bi_bootflags;	/* boot / reboot flag (for LynxOS) */
 	unsigned long bi_boot_params;	/* where this board expects params */
 	unsigned long bi_ip_addr;	/* IP Address */
-	unsigned char bi_enetaddr[6];	/* Ethernet adress */
 	unsigned short bi_ethspeed;	/* Ethernet speed in Mbps */
 	unsigned long bi_intfreq;	/* Internal Freq, in MHz */
 	unsigned long bi_busfreq;	/* Bus Freq, in MHz */
@@ -61,18 +60,6 @@ typedef struct bd_info {
 	unsigned long bi_flbfreq;	/* Flexbus Freq in MHz */
 #endif
 	unsigned long bi_baudrate;	/* Console Baudrate */
-
-#ifdef CONFIG_HAS_ETH1
-	/* second onboard ethernet port */
-	unsigned char bi_enet1addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH2
-	/* third onboard ethernet port */
-	unsigned char bi_enet2addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH3
-	unsigned char bi_enet3addr[6];
-#endif
 } bd_t;
 
 #endif				/* __ASSEMBLY__ */
diff --git a/include/asm-microblaze/u-boot.h b/include/asm-microblaze/u-boot.h
index 9db491e..543a6b1 100644
--- a/include/asm-microblaze/u-boot.h
+++ b/include/asm-microblaze/u-boot.h
@@ -41,7 +41,6 @@ typedef struct bd_info {
 	unsigned long	bi_sramstart;	/* start of SRAM memory */
 	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
 	unsigned long	bi_ip_addr;	/* IP Address */
-	unsigned char	bi_enetaddr[6]; /* Ethernet adress */
 	unsigned long	bi_baudrate;	/* Console Baudrate */
 } bd_t;
 
diff --git a/include/asm-mips/u-boot.h b/include/asm-mips/u-boot.h
index 9ecb9ac..d9c14ca 100644
--- a/include/asm-mips/u-boot.h
+++ b/include/asm-mips/u-boot.h
@@ -34,7 +34,6 @@
 typedef struct bd_info {
 	int		bi_baudrate;	/* serial console baudrate */
 	unsigned long	bi_ip_addr;	/* IP Address */
-	unsigned char	bi_enetaddr[6];	/* Ethernet adress */
 	unsigned long	bi_arch_number;	/* unique id for this board */
 	unsigned long	bi_boot_params;	/* where this board expects params */
 	unsigned long	bi_memstart;	/* start of DRAM memory */
diff --git a/include/asm-nios/u-boot.h b/include/asm-nios/u-boot.h
index 3436185..bdb6cf2 100644
--- a/include/asm-nios/u-boot.h
+++ b/include/asm-nios/u-boot.h
@@ -41,7 +41,6 @@ typedef struct bd_info {
 	unsigned long	bi_sramstart;	/* start of SRAM memory */
 	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
 	unsigned long	bi_ip_addr;	/* IP Address */
-	unsigned char	bi_enetaddr[6]; /* Ethernet adress */
 	unsigned long	bi_baudrate;	/* Console Baudrate */
 } bd_t;
 
diff --git a/include/asm-nios2/u-boot.h b/include/asm-nios2/u-boot.h
index de8c405..ec844d0 100644
--- a/include/asm-nios2/u-boot.h
+++ b/include/asm-nios2/u-boot.h
@@ -40,7 +40,6 @@ typedef struct bd_info {
 	unsigned long	bi_sramstart;	/* start of SRAM memory */
 	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
 	unsigned long	bi_ip_addr;	/* IP Address */
-	unsigned char	bi_enetaddr[6]; /* Ethernet adress */
 	unsigned long	bi_baudrate;	/* Console Baudrate */
 } bd_t;
 
diff --git a/include/asm-ppc/u-boot.h b/include/asm-ppc/u-boot.h
index 7451905..c16f32b 100644
--- a/include/asm-ppc/u-boot.h
+++ b/include/asm-ppc/u-boot.h
@@ -64,7 +64,6 @@ typedef struct bd_info {
 #endif
 	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
 	unsigned long	bi_ip_addr;	/* IP Address */
-	unsigned char	bi_enetaddr[6];	/* Ethernet adress */
 	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
 	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
 	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
@@ -100,24 +99,6 @@ typedef struct bd_info {
 	hymod_conf_t	bi_hymod_conf;	/* hymod configuration information */
 #endif
 
-#ifdef CONFIG_HAS_ETH1
-	/* second onboard ethernet port */
-	unsigned char   bi_enet1addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH2
-	/* third onboard ethernet port */
-	unsigned char	bi_enet2addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH3
-	unsigned char   bi_enet3addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH4
-	unsigned char   bi_enet4addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH5
-	unsigned char   bi_enet5addr[6];
-#endif
-
 #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
     defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \
     defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
diff --git a/include/asm-sh/u-boot.h b/include/asm-sh/u-boot.h
index e89c193..27d43b9 100644
--- a/include/asm-sh/u-boot.h
+++ b/include/asm-sh/u-boot.h
@@ -34,7 +34,6 @@ typedef struct bd_info {
 	unsigned long   bi_sramstart;   /* start of SRAM memory */
 	unsigned long   bi_sramsize;    /* size  of SRAM memory */
 	unsigned long   bi_ip_addr;     /* IP Address */
-	unsigned char   bi_enetaddr[6]; /* Ethernet adress */
 	unsigned long   bi_baudrate;    /* Console Baudrate */
 	unsigned long	bi_boot_params; /* where this board expects params */
 } bd_t;
diff --git a/include/asm-sparc/u-boot.h b/include/asm-sparc/u-boot.h
index c42e93c..209873f 100644
--- a/include/asm-sparc/u-boot.h
+++ b/include/asm-sparc/u-boot.h
@@ -52,22 +52,10 @@ typedef struct bd_info {
 	unsigned long bi_sramsize;	/* size  of SRAM memory */
 	unsigned long bi_bootflags;	/* boot / reboot flag (for LynxOS) */
 	unsigned long bi_ip_addr;	/* IP Address */
-	unsigned char bi_enetaddr[6];	/* Ethernet adress */
 	unsigned short bi_ethspeed;	/* Ethernet speed in Mbps */
 	unsigned long bi_intfreq;	/* Internal Freq, in MHz */
 	unsigned long bi_busfreq;	/* Bus Freq, in MHz */
 	unsigned long bi_baudrate;	/* Console Baudrate */
-#ifdef CONFIG_HAS_ETH1
-	/* second onboard ethernet port */
-	unsigned char bi_enet1addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH2
-	/* third onboard ethernet port */
-	unsigned char bi_enet2addr[6];
-#endif
-#ifdef CONFIG_HAS_ETH3
-	unsigned char bi_enet3addr[6];
-#endif
 } bd_t;
 
 #endif				/* __ASSEMBLY__ */
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function
  2009-02-14  7:23 ` [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function Mike Frysinger
@ 2009-02-14  9:22   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-02-14 18:03     ` Mike Frysinger
  2009-02-16 22:58   ` Wolfgang Denk
  1 sibling, 1 reply; 84+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-02-14  9:22 UTC (permalink / raw)
  To: u-boot

On 02:23 Sat 14 Feb     , Mike Frysinger wrote:
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> CC: Ben Warren <biggerbadderben@gmail.com>
> ---
>  board/kup/common/load_sernum_ethaddr.c |    4 ----
>  board/m501sk/m501sk.c                  |    5 -----
>  board/pcs440ep/pcs440ep.c              |    4 ----
>  board/tqc/tqm8xx/load_sernum_ethaddr.c |    4 ----
>  include/common.h                       |    2 --
>  5 files changed, 0 insertions(+), 19 deletions(-)
> 
do not drop from the common nslu2 patch use it
I'll send an update version within the few days

Best Regards,
J.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function
  2009-02-14  9:22   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-02-14 18:03     ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-14 18:03 UTC (permalink / raw)
  To: u-boot

On Saturday 14 February 2009 04:22:44 Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 02:23 Sat 14 Feb     , Mike Frysinger wrote:
> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> > CC: Ben Warren <biggerbadderben@gmail.com>
> > ---
> >  board/kup/common/load_sernum_ethaddr.c |    4 ----
> >  board/m501sk/m501sk.c                  |    5 -----
> >  board/pcs440ep/pcs440ep.c              |    4 ----
> >  board/tqc/tqm8xx/load_sernum_ethaddr.c |    4 ----
> >  include/common.h                       |    2 --
> >  5 files changed, 0 insertions(+), 19 deletions(-)
>
> do not drop from the common nslu2 patch use it
> I'll send an update version within the few days

i dont know what "common nslu2 patch" is.  there is no nslu2 code in mainline.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090214/f130a245/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-14  7:23 ` [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches Mike Frysinger
@ 2009-02-16 18:16   ` Scott Wood
  2009-02-16 18:57     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Scott Wood @ 2009-02-16 18:16 UTC (permalink / raw)
  To: u-boot

On Sat, Feb 14, 2009 at 02:23:10AM -0500, Mike Frysinger wrote:
> diff --git a/include/asm-ppc/u-boot.h b/include/asm-ppc/u-boot.h
> index 7451905..c16f32b 100644
> --- a/include/asm-ppc/u-boot.h
> +++ b/include/asm-ppc/u-boot.h
> @@ -64,7 +64,6 @@ typedef struct bd_info {
>  #endif
>  	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
>  	unsigned long	bi_ip_addr;	/* IP Address */
> -	unsigned char	bi_enetaddr[6];	/* Ethernet adress */
>  	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
>  	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
>  	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
> @@ -100,24 +99,6 @@ typedef struct bd_info {
>  	hymod_conf_t	bi_hymod_conf;	/* hymod configuration information */
>  #endif
>  
> -#ifdef CONFIG_HAS_ETH1
> -	/* second onboard ethernet port */
> -	unsigned char   bi_enet1addr[6];
> -#endif
> -#ifdef CONFIG_HAS_ETH2
> -	/* third onboard ethernet port */
> -	unsigned char	bi_enet2addr[6];
> -#endif
> -#ifdef CONFIG_HAS_ETH3
> -	unsigned char   bi_enet3addr[6];
> -#endif
> -#ifdef CONFIG_HAS_ETH4
> -	unsigned char   bi_enet4addr[6];
> -#endif
> -#ifdef CONFIG_HAS_ETH5
> -	unsigned char   bi_enet5addr[6];
> -#endif
> -
>  #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
>      defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \
>      defined(CONFIG_440EP) || defined(CONFIG_440GR) || \

This will break compatibility with pre-device-tree kernels.

bd_t is a public interface, albeit a deprecated one.

-Scott

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 18:16   ` Scott Wood
@ 2009-02-16 18:57     ` Mike Frysinger
  2009-02-16 19:00       ` Scott Wood
  2009-02-16 19:24       ` Wolfgang Denk
  0 siblings, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 18:57 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 13:16:38 Scott Wood wrote:
> On Sat, Feb 14, 2009 at 02:23:10AM -0500, Mike Frysinger wrote:
> > diff --git a/include/asm-ppc/u-boot.h b/include/asm-ppc/u-boot.h
> > index 7451905..c16f32b 100644
> > --- a/include/asm-ppc/u-boot.h
> > +++ b/include/asm-ppc/u-boot.h
> > @@ -64,7 +64,6 @@ typedef struct bd_info {
> > -	unsigned char	bi_enetaddr[6];	/* Ethernet adress */
> > -#ifdef CONFIG_HAS_ETH1
> > -	/* second onboard ethernet port */
> > -	unsigned char   bi_enet1addr[6];
> > -#endif
> > -#ifdef CONFIG_HAS_ETH2
> > -	/* third onboard ethernet port */
> > -	unsigned char	bi_enet2addr[6];
> > -#endif
> > -#ifdef CONFIG_HAS_ETH3
> > -	unsigned char   bi_enet3addr[6];
> > -#endif
> > -#ifdef CONFIG_HAS_ETH4
> > -	unsigned char   bi_enet4addr[6];
> > -#endif
> > -#ifdef CONFIG_HAS_ETH5
> > -	unsigned char   bi_enet5addr[6];
> > -#endif
>
> This will break compatibility with pre-device-tree kernels.
>
> bd_t is a public interface, albeit a deprecated one.

the fact that the size can change based on board configs makes it already a 
pretty unreliable ABI ...

at any rate, is there a define that can be keyed off of ?  CONFIG_HAS_FDT or 
some such junk ?  then the behavior can be changed to like:
#ifndef CONFIG_HAS_FDT
	/* ABI compat junk */
	uchar bi_padding_was_enetaddr[6];
#endif
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 18:57     ` Mike Frysinger
@ 2009-02-16 19:00       ` Scott Wood
  2009-02-16 19:29         ` Mike Frysinger
  2009-02-16 19:24       ` Wolfgang Denk
  1 sibling, 1 reply; 84+ messages in thread
From: Scott Wood @ 2009-02-16 19:00 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Monday 16 February 2009 13:16:38 Scott Wood wrote:
>> This will break compatibility with pre-device-tree kernels.
>>
>> bd_t is a public interface, albeit a deprecated one.
> 
> the fact that the size can change based on board configs makes it already a 
> pretty unreliable ABI ...

Sure, that's why it's deprecated. :-)

> at any rate, is there a define that can be keyed off of ?  CONFIG_HAS_FDT or 
> some such junk ?  then the behavior can be changed to like:
> #ifndef CONFIG_HAS_FDT
> 	/* ABI compat junk */
> 	uchar bi_padding_was_enetaddr[6];
> #endif

Why not just leave the bd_t alone, until such a time as we can get rid 
of it altogether?

Note that just because we support booting with device trees doesn't mean 
we don't also support booting legacy kernels.

-Scott

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 18:57     ` Mike Frysinger
  2009-02-16 19:00       ` Scott Wood
@ 2009-02-16 19:24       ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 19:24 UTC (permalink / raw)
  To: u-boot

Dear Mike,

In message <200902161357.54008.vapier@gentoo.org> you wrote:
>
> > > diff --git a/include/asm-ppc/u-boot.h b/include/asm-ppc/u-boot.h
> > > index 7451905..c16f32b 100644
> > > --- a/include/asm-ppc/u-boot.h
> > > +++ b/include/asm-ppc/u-boot.h
> > > @@ -64,7 +64,6 @@ typedef struct bd_info {
> > > -	unsigned char	bi_enetaddr[6];	/* Ethernet adress */
> > > -#ifdef CONFIG_HAS_ETH1
> > > -	/* second onboard ethernet port */
> > > -	unsigned char   bi_enet1addr[6];
> > > -#endif
> > > -#ifdef CONFIG_HAS_ETH2
> > > -	/* third onboard ethernet port */
> > > -	unsigned char	bi_enet2addr[6];
> > > -#endif
> > > -#ifdef CONFIG_HAS_ETH3
> > > -	unsigned char   bi_enet3addr[6];
> > > -#endif
> > > -#ifdef CONFIG_HAS_ETH4
> > > -	unsigned char   bi_enet4addr[6];
> > > -#endif
> > > -#ifdef CONFIG_HAS_ETH5
> > > -	unsigned char   bi_enet5addr[6];
> > > -#endif
> >
> > This will break compatibility with pre-device-tree kernels.
> >
> > bd_t is a public interface, albeit a deprecated one.

Crect - and one that must be kept untouched.

> at any rate, is there a define that can be keyed off of ?  CONFIG_HAS_FDT or 
> some such junk ?  then the behavior can be changed to like:
> #ifndef CONFIG_HAS_FDT
> 	/* ABI compat junk */
> 	uchar bi_padding_was_enetaddr[6];
> #endif

No. This interface must be kept as is. 

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: wd at denx.de
Motto of the Electrical Engineer: Working computer hardware is a  lot
like an erect penis: it stays up as long as you don't fuck with it.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 19:00       ` Scott Wood
@ 2009-02-16 19:29         ` Mike Frysinger
  2009-02-16 19:47           ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 19:29 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 14:00:59 Scott Wood wrote:
> Mike Frysinger wrote:
> > at any rate, is there a define that can be keyed off of ?  CONFIG_HAS_FDT
> > or some such junk ?  then the behavior can be changed to like:
> > #ifndef CONFIG_HAS_FDT
> > 	/* ABI compat junk */
> > 	uchar bi_padding_was_enetaddr[6];
> > #endif
>
> Why not just leave the bd_t alone, until such a time as we can get rid
> of it altogether?
>
> Note that just because we support booting with device trees doesn't mean
> we don't also support booting legacy kernels.

the name has to go.  u-boot no longer uses that field and leaving it in will 
simply lead to code misusing it creeping it back into the tree.  whether you 
choose to force the warts on everyone is up to you ... i'm not a ppc consumer 
so i could care less.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/ffcbb7a6/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 19:29         ` Mike Frysinger
@ 2009-02-16 19:47           ` Wolfgang Denk
  2009-02-16 19:59             ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 19:47 UTC (permalink / raw)
  To: u-boot

Dear Mike,

In message <200902161429.10360.vapier@gentoo.org> you wrote:
> 
> > > at any rate, is there a define that can be keyed off of ?  CONFIG_HAS_FDT
> > > or some such junk ?  then the behavior can be changed to like:
> > > #ifndef CONFIG_HAS_FDT
> > > 	/* ABI compat junk */
> > > 	uchar bi_padding_was_enetaddr[6];
> > > #endif
> >
> > Why not just leave the bd_t alone, until such a time as we can get rid
> > of it altogether?
> >
> > Note that just because we support booting with device trees doesn't mean
> > we don't also support booting legacy kernels.
>
> the name has to go.  u-boot no longer uses that field and leaving it in will 
> simply lead to code misusing it creeping it back into the tree.  whether you 
> choose to force the warts on everyone is up to you ... i'm not a ppc consumer 
> so i could care less.

You are not permitted  to  change  this  interface.  It  must  remain
stable.  There  are  systems  out  there  running  really  old kernel
versions, and every now and then they may even need to update  U-Boot
to adapt it for recent hardware changes, while they cannot change the
kernel.  It  is  mandatory  that even old 2.4 kernel versions must be
bootable with recent versions of U-Boot.

As mentioned before, bd_info is a binary interfwace between U-Boot and
the Linux kernel, and it must not be changed.

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: wd at denx.de
Research is what I'm doing when I don't know what I'm doing.
                                                 -- Wernher von Braun

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 19:47           ` Wolfgang Denk
@ 2009-02-16 19:59             ` Mike Frysinger
  2009-02-16 20:14               ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 19:59 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 14:47:52 Wolfgang Denk wrote:
> In message <200902161429.10360.vapier@gentoo.org> you wrote:
> > > > at any rate, is there a define that can be keyed off of ? 
> > > > CONFIG_HAS_FDT or some such junk ?  then the behavior can be changed
> > > > to like: #ifndef CONFIG_HAS_FDT
> > > > 	/* ABI compat junk */
> > > > 	uchar bi_padding_was_enetaddr[6];
> > > > #endif
> > >
> > > Why not just leave the bd_t alone, until such a time as we can get rid
> > > of it altogether?
> > >
> > > Note that just because we support booting with device trees doesn't
> > > mean we don't also support booting legacy kernels.
> >
> > the name has to go.  u-boot no longer uses that field and leaving it in
> > will simply lead to code misusing it creeping it back into the tree. 
> > whether you choose to force the warts on everyone is up to you ... i'm
> > not a ppc consumer so i could care less.
>
> You are not permitted  to  change  this  interface.  It  must  remain
> stable.  There  are  systems  out  there  running  really  old kernel
> versions, and every now and then they may even need to update  U-Boot
> to adapt it for recent hardware changes, while they cannot change the
> kernel.  It  is  mandatory  that even old 2.4 kernel versions must be
> bootable with recent versions of U-Boot.
>
> As mentioned before, bd_info is a binary interfwace between U-Boot and
> the Linux kernel, and it must not be changed.

i'm not talking about changing the binary aspect of it.  i'm talking about 
changing the API.  two completely different things.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/4e7e55cb/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 19:59             ` Mike Frysinger
@ 2009-02-16 20:14               ` Wolfgang Denk
  2009-02-16 20:49                 ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 20:14 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161459.45065.vapier@gentoo.org> you wrote:
>
> > As mentioned before, bd_info is a binary interfwace between U-Boot and
> > the Linux kernel, and it must not be changed.
>
> i'm not talking about changing the binary aspect of it.  i'm talking about
> changing the API.  two completely different things.

Then I don't understand what you are talking about or what your patch
is doing. To me it looks as if you were removing the bi_enetaddr[]
resp. bi_enet?addr[] from the bd_info structure.

Such a modification is not permitted, the bd_info structure must be
kept constant and unchanged *and* the respective fields must be
correctly initialized before booting the Linux kernel.

This is mandatory.

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: wd at denx.de
Even if you aren't in doubt, consider the mental welfare of the  per-
son who has to maintain the code after you, and who will probably put
parens in the wrong place.          - Larry Wall in the perl man page

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 20:14               ` Wolfgang Denk
@ 2009-02-16 20:49                 ` Mike Frysinger
  2009-02-16 20:54                   ` Scott Wood
  2009-02-16 21:03                   ` Wolfgang Denk
  0 siblings, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 20:49 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 15:14:32 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > > As mentioned before, bd_info is a binary interfwace between U-Boot and
> > > the Linux kernel, and it must not be changed.
> >
> > i'm not talking about changing the binary aspect of it.  i'm talking
> > about changing the API.  two completely different things.
>
> Then I don't understand what you are talking about or what your patch
> is doing. To me it looks as if you were removing the bi_enetaddr[]
> resp. bi_enet?addr[] from the bd_info structure.

the discussion has moved on.  the original patch removed the fields, but in 
the follow ups it was proposed simply renaming them.  please review the 
context of each reply.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/215c8324/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 20:49                 ` Mike Frysinger
@ 2009-02-16 20:54                   ` Scott Wood
  2009-02-16 21:13                     ` Mike Frysinger
  2009-02-16 21:03                   ` Wolfgang Denk
  1 sibling, 1 reply; 84+ messages in thread
From: Scott Wood @ 2009-02-16 20:54 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Monday 16 February 2009 15:14:32 Wolfgang Denk wrote:
>> In message Mike Frysinger wrote:
>>>> As mentioned before, bd_info is a binary interfwace between U-Boot and
>>>> the Linux kernel, and it must not be changed.
>>> i'm not talking about changing the binary aspect of it.  i'm talking
>>> about changing the API.  two completely different things.
>> Then I don't understand what you are talking about or what your patch
>> is doing. To me it looks as if you were removing the bi_enetaddr[]
>> resp. bi_enet?addr[] from the bd_info structure.
> 
> the discussion has moved on.  the original patch removed the fields, but in 
> the follow ups it was proposed simply renaming them.  please review the 
> context of each reply.

What do we gain from renaming them?  We still need to fill in the MAC 
addresses for compatibility.  If you want to discourage new internal 
users, use a comment (preferably a giant do-not-touch sign over the 
entire bd_t).

-Scott

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 20:49                 ` Mike Frysinger
  2009-02-16 20:54                   ` Scott Wood
@ 2009-02-16 21:03                   ` Wolfgang Denk
  2009-02-16 21:18                     ` Mike Frysinger
  1 sibling, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 21:03 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161549.48687.vapier@gentoo.org> you wrote:
>
> > Then I don't understand what you are talking about or what your patch
> > is doing. To me it looks as if you were removing the bi_enetaddr[]
> > resp. bi_enet?addr[] from the bd_info structure.
>
> the discussion has moved on.  the original patch removed the fields, but in
> the follow ups it was proposed simply renaming them.  please review the 
> context of each reply.

You just mentioned in one message a (IMHO silly) name
bi_padding_was_enetaddr[] which did not look to me as if you intended
to keep the funtionality.

And even renaming is BAD as it breaks compatibility with the Linux
kernel. It's bad enough that we have a binary data structure as a
critical interface, but suing different variable names for the same
fields would make it definitely worse.

Please leave that structure untouched.

This is my final statement on this issue.

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: wd at denx.de
The biggest difference between time and space is that you can't reuse
time.                                                 - Merrick Furst

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 20:54                   ` Scott Wood
@ 2009-02-16 21:13                     ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 21:13 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 15:54:06 Scott Wood wrote:
> Mike Frysinger wrote:
> > On Monday 16 February 2009 15:14:32 Wolfgang Denk wrote:
> >> In message Mike Frysinger wrote:
> >>>> As mentioned before, bd_info is a binary interfwace between U-Boot and
> >>>> the Linux kernel, and it must not be changed.
> >>>
> >>> i'm not talking about changing the binary aspect of it.  i'm talking
> >>> about changing the API.  two completely different things.
> >>
> >> Then I don't understand what you are talking about or what your patch
> >> is doing. To me it looks as if you were removing the bi_enetaddr[]
> >> resp. bi_enet?addr[] from the bd_info structure.
> >
> > the discussion has moved on.  the original patch removed the fields, but
> > in the follow ups it was proposed simply renaming them.  please review
> > the context of each reply.
>
> What do we gain from renaming them?  We still need to fill in the MAC
> addresses for compatibility.  If you want to discourage new internal
> users, use a comment (preferably a giant do-not-touch sign over the
> entire bd_t).

people dont read comments.  that method of deprecation is pure wishful 
thinking.  people forward porting old code (boards/drivers/whatever) or even 
writing new code will build it up and if it seems to work, submit it.  and no 
amount of review is 100% all the time.  if, instead, they got a build error 
straight up front, they'd sure as hell figure out why and get it fixed.  this 
is where a comment in the struct that says "this is legacy, do not touch, go 
read README.macaddr" would actually be read and be useful.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/a9c48be3/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 21:03                   ` Wolfgang Denk
@ 2009-02-16 21:18                     ` Mike Frysinger
  2009-02-16 23:13                       ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 21:18 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 16:03:36 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > > Then I don't understand what you are talking about or what your patch
> > > is doing. To me it looks as if you were removing the bi_enetaddr[]
> > > resp. bi_enet?addr[] from the bd_info structure.
> >
> > the discussion has moved on.  the original patch removed the fields, but
> > in the follow ups it was proposed simply renaming them.  please review
> > the context of each reply.
>
> You just mentioned in one message a (IMHO silly) name
> bi_padding_was_enetaddr[] which did not look to me as if you intended
> to keep the funtionality.

padding/deprecated/whatever.  it's the same thing: it becomes internal/legacy 
only and no new code touches it.

> And even renaming is BAD as it breaks compatibility with the Linux
> kernel.  It's bad enough that we have a binary data structure as a
> critical interface, but suing different variable names for the same
> fields would make it definitely worse.

that doesnt make any sense at all.  the kernel isnt passed the structure as 
seen in the C language, it gets passed a binary blob.  how the kernel chooses 
to interpret it is up to the kernel.

> Please leave that structure untouched.
>
> This is my final statement on this issue.

you'd think the maintainer would be more open to talking about issues instead 
of closing their mind and ignoring improvements
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/dcdad27c/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-14  7:22 ` [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's Mike Frysinger
@ 2009-02-16 22:28   ` Wolfgang Denk
  2009-02-17  0:00     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:28 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-2-git-send-email-vapier@gentoo.org> you wrote:
> Declare new utility functions for converting between the environment
> variables (eth*addr) and the binary MAC address representation.  This way
> we can unify all the random places that already do this kind of thing.
...
> +#ifdef CONFIG_CMD_NET
> +char *str_enetaddr(char *buf, const uchar *enetaddr)
> +{
> +	sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
> +		enetaddr[0], enetaddr[1], enetaddr[2],
> +		enetaddr[3], enetaddr[4], enetaddr[5]);
> +	return buf;
> +}
> +
> +void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
> +{
> +	char *end;
> +	int i;

Empty line here...

> +	for (i = 0; i < 6; ++i) {
> +		enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
> +		if (addr)
> +			addr = (*end) ? end + 1 : end;
> +	}
> +}
> +
> +int eth_getenv_enetaddr(char *name, uchar *enetaddr)
> +{
> +	int ret = 0;
> +	char *addr = getenv(name);

Empty line here...

> +	if (!addr)
> +		ret = -1;
> +	eth_parse_enetaddr(addr, enetaddr);
> +	return ret;
> +}
> +
> +int eth_setenv_enetaddr(char *name, const uchar *enetaddr)
> +{
> +	char buf[20];

Empty line here...

and so on...

> +	return setenv(name, str_enetaddr(buf, enetaddr));
...

> +					printf ("Address in SROM is         %s\n",
> +						str_enetaddr(enetvar, dev->enetaddr));
> +					printf ("Address in environment is  %s\n",
> +						str_enetaddr(enetvar, env_enetaddr));

Hm... Linux has a printk() format specifier for MAC addresses. Sounds
like a clever idea to me. Maybe we should borrow that code?

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: wd at denx.de
You can do this in a number of ways.     IBM chose to do all of them.
Why do you find that funny?        -- D. Taylor, Computer Science 350

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage
  2009-02-14  7:22 ` [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage Mike Frysinger
@ 2009-02-16 22:38   ` Wolfgang Denk
  2009-02-17  0:12     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:38 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-3-git-send-email-vapier@gentoo.org> you wrote:
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> CC: Ben Warren <biggerbadderben@gmail.com>
> ---
>  doc/README.enetaddr |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 96 insertions(+), 0 deletions(-)
>  create mode 100644 doc/README.enetaddr
...
> +Here are the places where MAC addresses might be stored:
> +
> + - board-specific location (eeprom, dedicated flash, ...)
> +	Note: only used when mandatory due to hardware design etc...
> +
> + - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR)
> +	Note: this is the preferred way to permanently store MAC addresses
> +
> + - ethernet data (struct eth_device -> enetaddr)
> +	Note: these are temporary copies of the MAC address which exist only
> +	      after the respective init steps have run and only to make usage
> +	      in other places easier (to avoid constant env lookup/parsing)

    - struct bd_info and/or device tree
        Note: these are temporary copies of the MAC address only foir
	the purpose to pass this information to an OS kernel we are
	about to boot

> +The common environment code will take care of passing environment changes to
> +the global data.  This happens automatically whenever setenv() updates the
> +relevant ethaddr variables.

Didn't we just remove the MAC address information from the global
data?

> +Any other common code that wishes to access the MAC address should then query
> +the global data directly.  No one should be looking in the environment for any
> +addresses.

Is this still valid?

> +Print the MAC address into the specified storage.  Caller should make sure the
> +storage is sufficient (20 bytes is fine).  The pointer used for storage is
> +returned.
> +char buf[20];
> +uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
> +str_enetaddr(buf, enetaddr);
> +printf("The MAC is %s\n", buf);
> +/* the buf variable is now set to "00:11:22:33:44:55" */

I think we should instead borrow the 'M' (and probably also the 'I',
but that's a different story) format specifiers from the Linux
"lib/vsprintf.c" implementation ?

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: wd at denx.de
Real Programmers always confuse Christmas and Halloween because
OCT 31 == DEC 25 !  - Andrew Rutherford (andrewr at ucs.adelaide.edu.au)

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 10/27] boards: get mac address from environment
  2009-02-14  7:22 ` [U-Boot] [PATCH 10/27] boards: " Mike Frysinger
@ 2009-02-16 22:46   ` Wolfgang Denk
  2009-02-16 23:55     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:46 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-11-git-send-email-vapier@gentoo.org> you wrote:
> The boards that get converted here to use the environment for the mac
> address rather than global data:

Hmm... is this commit message correct? Makes little sense to me....

> diff --git a/board/etin/debris/debris.c b/board/etin/debris/debris.c
> index 227c49a..3dec7cc 100644
> --- a/board/etin/debris/debris.c
> +++ b/board/etin/debris/debris.c
> @@ -174,8 +174,10 @@ void nvram_write(long dest, const void *src, size_t count)
>  int misc_init_r(void)
>  {
>  	/* Write ethernet addr in NVRAM for VxWorks */
> -	nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
> -			(char*)&gd->bd->bi_enetaddr[0], 6);
> +	uchar ethaddr[6];
> +	if (eth_getenv_enetaddr("ethaddr", ethaddr))

Please move declaration above comment (and add an empty line).

...
> -static int get_mac_address (int id, u8 * mac, char *string, int size)
> +static int get_mac_address (int id, u8 *mac)
>  {
> -	if (size < 6 * 3)
> -		return -1;
> -
>  	i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
> -	return sprintf (string, "%02x:%02x:%02x:%02x:%02x:%02x",
> -				mac[0], mac[1], mac[2],
> -				mac[3], mac[4], mac[5]);
>  }

This one looks broken to me. At least it returns random data.


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: wd at denx.de
ADVISORY:  There is  an  Extremely Small  but  Nonzero  Chance  That,
Through a Process Know as "Tunneling," This Product May Spontaneously
Disappear  from Its Present Location and Reappear at Any Random Place
in the Universe, Including Your Neighbor's Domicile. The Manufacturer
Will Not Be Responsible for Any Damages  or  Inconvenience  That  May
Result.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 16/27] cpu/: get mac address from environment
  2009-02-14  7:22 ` [U-Boot] [PATCH 16/27] cpu/: " Mike Frysinger
@ 2009-02-16 22:52   ` Wolfgang Denk
  2009-02-16 23:56     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:52 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-17-git-send-email-vapier@gentoo.org> you wrote:
> The environment is the canonical storage location of the mac address, so
> we're killing off the global data location and moving everything to
> querying the env directly.
...
> --- a/cpu/mpc8260/ether_scc.c
> +++ b/cpu/mpc8260/ether_scc.c
> @@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t *bis)
>      volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
>      scc_enet_t *pram_ptr;
>      uint dpaddr;
> +	uchar ea[6];
>  
>      rxIdx = 0;
>      txIdx = 0;
> @@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t *bis)
>      pram_ptr->sen_gaddr3 = 0x0;   /* Group Address Filter 3 (unused) */
>      pram_ptr->sen_gaddr4 = 0x0;   /* Group Address Filter 4 (unused) */
>  
> -#  define ea bis->bi_enetaddr
> +	eth_getenv_enetaddr("ethaddr", ea);
>      pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
>      pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
>      pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
> -#  undef ea

I see that we have bad indentations here, but please either provide a
separate patch to fix the cosing style, or stich with your new code to
the existing one.


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: wd at denx.de
There's an old proverb that says just about whatever you want it to.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 21/27] cmc_pu2: get mac address from environment
  2009-02-14  7:23 ` [U-Boot] [PATCH 21/27] cmc_pu2: " Mike Frysinger
@ 2009-02-16 22:56   ` Wolfgang Denk
  2009-02-17  0:03     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:56 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-22-git-send-email-vapier@gentoo.org> you wrote:
> The environment is the canonical storage location of the mac address, so
> we're killing off the global data location and moving everything to
> querying the env directly.
> 
> Also rename load_sernum_ethaddr() to misc_init_r() so we don't need to
> handle this board specially in common ARM code.
...
> -#ifdef CONFIG_CMC_PU2
> -	load_sernum_ethaddr ();
> -#endif /* CONFIG_CMC_PU2 */
> -

If we bisect here, we have broken boards because load_sernum_ethaddr()
is no longer called but the new init code is not installed yet.

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: wd at denx.de
This is an unauthorized cybernetic announcement.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-14  7:23 ` [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init Mike Frysinger
@ 2009-02-16 22:57   ` Wolfgang Denk
  2009-02-17  0:05     ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:57 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-23-git-send-email-vapier@gentoo.org> you wrote:
> The environment is the canonical storage location of the mac address, so
> we're killing off the global data location and moving everything to
> querying the env directly.
> 
> Move all the work of load_sernum_ethaddr() into a local load_ethaddr()
> func and call that from misc_init_r().  We leave load_sernum_ethaddr()
> as a stub so that it can be removed from all places in a later commit.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> CC: Stefan Roese <sr@denx.de>
> CC: Ben Warren <biggerbadderben@gmail.com>
...
> +void load_sernum_ethaddr (void)
> +{
> +}
> +

See previous comments - please do not add dead code just to remove it
later.

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: wd at denx.de
I think it's a new feature. Don't tell anyone it was an accident. :-)
  -- Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 24/27] tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
  2009-02-14  7:23 ` [U-Boot] [PATCH 24/27] tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() Mike Frysinger
@ 2009-02-16 22:58   ` Wolfgang Denk
  0 siblings, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:58 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-25-git-send-email-vapier@gentoo.org> you wrote:
> Rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() and have board
> init code call it rather than the common ppc board code.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> CC: Ben Warren <biggerbadderben@gmail.com>
> ---
>  board/tqc/tqm8xx/load_sernum_ethaddr.c |    6 +++++-
>  board/tqc/tqm8xx/tqm8xx.c              |    3 +++
>  2 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/board/tqc/tqm8xx/load_sernum_ethaddr.c b/board/tqc/tqm8xx/load_sernum_ethaddr.c
> index d269902..ea534f7 100644
> --- a/board/tqc/tqm8xx/load_sernum_ethaddr.c
> +++ b/board/tqc/tqm8xx/load_sernum_ethaddr.c
> @@ -49,7 +49,7 @@
>   * 4) Number of additional MAC addresses
>   */
>  
> -void load_sernum_ethaddr (void)
> +void tqc_load_sernum_ethaddr (void)
>  {
>  	unsigned char *hwi;
>  	unsigned char  serial [CONFIG_SYS_HWINFO_SIZE];
> @@ -103,3 +103,7 @@ void load_sernum_ethaddr (void)
>  		setenv ((char *)"ethaddr", (char *)ethaddr);
>  	}
>  }
> +
> +void load_sernum_ethaddr (void)
> +{
> +}
> diff --git a/board/tqc/tqm8xx/tqm8xx.c b/board/tqc/tqm8xx/tqm8xx.c
> index e065d69..ca91554 100644
> --- a/board/tqc/tqm8xx/tqm8xx.c
> +++ b/board/tqc/tqm8xx/tqm8xx.c
> @@ -449,11 +449,14 @@ int board_early_init_r (void)
>  
>  
>  #ifdef CONFIG_MISC_INIT_R
> +extern void tqc_load_sernum_ethaddr(void);
>  int misc_init_r (void)
>  {
>  	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
>  	volatile memctl8xx_t *memctl = &immap->im_memctl;
>  
> +	tqc_load_sernum_ethaddr();
> +
>  #ifdef	CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ
>  	int scy, trlx, flash_or_timing, clk_diff;

See previous review comments - NAK.

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: wd at denx.de
FORTRAN? The syntactically incorrect statement "DO 10 I = 1.10"  will
parse  and  generate  code  creating  a  variable, DO10I, as follows:
"DO10I = 1.10" If that doesn't terrify you, it should.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 23/27] kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr()
  2009-02-14  7:23 ` [U-Boot] [PATCH 23/27] kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr() Mike Frysinger
@ 2009-02-16 22:58   ` Wolfgang Denk
  0 siblings, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:58 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-24-git-send-email-vapier@gentoo.org> you wrote:
> Rename load_sernum_ethaddr() to kup_load_sernum_ethaddr() and have board
> init code call it rather than the common ppc board code.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> CC: Ben Warren <biggerbadderben@gmail.com>
> ---
>  board/kup/common/load_sernum_ethaddr.c |    6 +++++-
>  board/kup/kup4k/kup4k.c                |    3 +++
>  board/kup/kup4x/kup4x.c                |    4 +++-
>  3 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/board/kup/common/load_sernum_ethaddr.c b/board/kup/common/load_sernum_ethaddr.c
> index 741e9a5..5f725f8 100644
> --- a/board/kup/common/load_sernum_ethaddr.c
> +++ b/board/kup/common/load_sernum_ethaddr.c
> @@ -51,7 +51,7 @@
>  #define ETHADDR_TOKEN "ethaddr="
>  #define LCD_TOKEN "lcd="
>  
> -void load_sernum_ethaddr (void)
> +void kup_load_sernum_ethaddr (void)
>  {
>  	unsigned char *hwi;
>  	char *var;
> @@ -92,3 +92,7 @@ void load_sernum_ethaddr (void)
>  		}
>  	}
>  }
> +
> +void load_sernum_ethaddr (void)
> +{
> +}
> diff --git a/board/kup/kup4k/kup4k.c b/board/kup/kup4k/kup4k.c
> index df3ffb4..f49c85a 100644
> --- a/board/kup/kup4k/kup4k.c
> +++ b/board/kup/kup4k/kup4k.c
> @@ -233,6 +233,8 @@ phys_size_t initdram (int board_type)
>  
>  /* ------------------------------------------------------------------------- */
>  
> +extern void kup_load_sernum_ethaddr(void);
> +
>  int misc_init_r (void)
>  {
>  #ifdef CONFIG_STATUS_LED
> @@ -250,6 +252,7 @@ int misc_init_r (void)
>  	immap->im_ioport.iop_papar &= ~0x80;
>  	immap->im_ioport.iop_padat |= 0x80;	/* turn it off */
>  #endif
> +	kup_load_sernum_ethaddr();
>  	setenv("hw","4k");
>  	poweron_key();
>  	return (0);
> diff --git a/board/kup/kup4x/kup4x.c b/board/kup/kup4x/kup4x.c
> index c5b742d..b5b7595 100644
> --- a/board/kup/kup4x/kup4x.c
> +++ b/board/kup/kup4x/kup4x.c
> @@ -292,10 +292,11 @@ static long int dram_size (long int mamr_value, long int *base,
>  }
>  #endif
>  
> +extern void kup_load_sernum_ethaddr(void);
> +
>  int misc_init_r (void)
>  {
>  	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
> -
>  #ifdef CONFIG_IDE_LED
>  	/* Configure PA8 as output port */
>  	immap->im_ioport.iop_padir |= 0x80;
> @@ -306,6 +307,7 @@ int misc_init_r (void)
>  #ifdef KUP4X_USB
>  	usb_init_kup4x ();
>  #endif
> +	kup_load_sernum_ethaddr();
>  	setenv ("hw", "4x");
>  	poweron_key ();
>  	return (0);

See previous review comments - NAK.

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: wd at denx.de
There is a biblical analogy I'd like to draw here.   Casts are to C++
Programmers what the apple was to Eve.         - Scott Douglas Meyers

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function
  2009-02-14  7:23 ` [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function Mike Frysinger
  2009-02-14  9:22   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-02-16 22:58   ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 22:58 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <1234596190-524-27-git-send-email-vapier@gentoo.org> you wrote:
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> CC: Ben Warren <biggerbadderben@gmail.com>
> ---
>  board/kup/common/load_sernum_ethaddr.c |    4 ----
>  board/m501sk/m501sk.c                  |    5 -----
>  board/pcs440ep/pcs440ep.c              |    4 ----
>  board/tqc/tqm8xx/load_sernum_ethaddr.c |    4 ----
>  include/common.h                       |    2 --
>  5 files changed, 0 insertions(+), 19 deletions(-)

See previous review comments - NAK.

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: wd at denx.de
He'd been wrong, there _was_ a light at the end of the tunnel, and it
was a flamethrower.                         - Terry Pratchett, _Mort_

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 21:18                     ` Mike Frysinger
@ 2009-02-16 23:13                       ` Wolfgang Denk
  2009-02-17  0:18                         ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-16 23:13 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161618.16726.vapier@gentoo.org> you wrote:
>
> > And even renaming is BAD as it breaks compatibility with the Linux
> > kernel.  It's bad enough that we have a binary data structure as a
> > critical interface, but suing different variable names for the same
> > fields would make it definitely worse.
>
> that doesnt make any sense at all.  the kernel isnt passed the structure as 
> seen in the C language, it gets passed a binary blob.  how the kernel chooses 
> to interpret it is up to the kernel.

And how do you check for problems? At least initially by comparing
the source code. Why making this more difficult than necessary?

> > Please leave that structure untouched.
> >
> > This is my final statement on this issue.
>
> you'd think the maintainer would be more open to talking about issues instead 
> of closing their mind and ignoring improvements

We have discussed this here for some time now, and I considered the
pros and cons and made up my mind. YMMV.

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: wd at denx.de
God is real, unless declared integer.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 10/27] boards: get mac address from environment
  2009-02-16 22:46   ` Wolfgang Denk
@ 2009-02-16 23:55     ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 23:55 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 17:46:24 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > The boards that get converted here to use the environment for the mac
> > address rather than global data:
>
> Hmm... is this commit message correct? Makes little sense to me....

looks correct to me ... the boards are moved from using the global data to 
using the environment

> > diff --git a/board/etin/debris/debris.c b/board/etin/debris/debris.c
> > index 227c49a..3dec7cc 100644
> > --- a/board/etin/debris/debris.c
> > +++ b/board/etin/debris/debris.c
> > @@ -174,8 +174,10 @@ void nvram_write(long dest, const void *src, size_t
> > count) int misc_init_r(void)
> >  {
> >  	/* Write ethernet addr in NVRAM for VxWorks */
> > -	nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
> > -			(char*)&gd->bd->bi_enetaddr[0], 6);
> > +	uchar ethaddr[6];
> > +	if (eth_getenv_enetaddr("ethaddr", ethaddr))
>
> Please move declaration above comment (and add an empty line).

ok

> > -static int get_mac_address (int id, u8 * mac, char *string, int size)
> > +static int get_mac_address (int id, u8 *mac)
> >  {
> > -	if (size < 6 * 3)
> > -		return -1;
> > -
> >  	i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
> > -	return sprintf (string, "%02x:%02x:%02x:%02x:%02x:%02x",
> > -				mac[0], mac[1], mac[2],
> > -				mac[3], mac[4], mac[5]);
> >  }
>
> This one looks broken to me. At least it returns random data.

yes, i broke the return value.  not that it would make a difference at runtime 
as nowhere was the return value actually checked/used.  fixed though, thanks.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/25976e62/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 16/27] cpu/: get mac address from environment
  2009-02-16 22:52   ` Wolfgang Denk
@ 2009-02-16 23:56     ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-16 23:56 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 17:52:55 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > --- a/cpu/mpc8260/ether_scc.c
> > +++ b/cpu/mpc8260/ether_scc.c
> > @@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t
> > *bis) volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
> >      scc_enet_t *pram_ptr;
> >      uint dpaddr;
> > +	uchar ea[6];
> >
> >      rxIdx = 0;
> >      txIdx = 0;
> > @@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t
> > *bis) pram_ptr->sen_gaddr3 = 0x0;   /* Group Address Filter 3 (unused) */
> > pram_ptr->sen_gaddr4 = 0x0;   /* Group Address Filter 4 (unused) */
> >
> > -#  define ea bis->bi_enetaddr
> > +	eth_getenv_enetaddr("ethaddr", ea);
> >      pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
> >      pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
> >      pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
> > -#  undef ea
>
> I see that we have bad indentations here, but please either provide a
> separate patch to fix the cosing style, or stich with your new code to
> the existing one.

oh, looks like this file uses sucky GNU style.  i didnt notice as i use 4-
spaced tabs.  i'll just change my tabs to match existing style as the cleanup 
would pretty much rewrite the whole file.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/58b8c8e2/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-16 22:28   ` Wolfgang Denk
@ 2009-02-17  0:00     ` Mike Frysinger
  2009-02-17  0:13       ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:00 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 17:28:24 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > +					printf ("Address in SROM is         %s\n",
> > +						str_enetaddr(enetvar, dev->enetaddr));
> > +					printf ("Address in environment is  %s\n",
> > +						str_enetaddr(enetvar, env_enetaddr));
>
> Hm... Linux has a printk() format specifier for MAC addresses. Sounds
> like a clever idea to me. Maybe we should borrow that code?

it does eh ?  that certainly sounds a lot better than str_enetaddr() as every 
place i changed to use it was in a printf() string.  where in the kernel is 
that code ?  i looked in lib/vsprintf.c but couldnt find it.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/684ef220/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 21/27] cmc_pu2: get mac address from environment
  2009-02-16 22:56   ` Wolfgang Denk
@ 2009-02-17  0:03     ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:03 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 17:56:17 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > The environment is the canonical storage location of the mac address, so
> > we're killing off the global data location and moving everything to
> > querying the env directly.
> >
> > Also rename load_sernum_ethaddr() to misc_init_r() so we don't need to
> > handle this board specially in common ARM code.
>
> ...
>
> > -#ifdef CONFIG_CMC_PU2
> > -	load_sernum_ethaddr ();
> > -#endif /* CONFIG_CMC_PU2 */
> > -
>
> If we bisect here, we have broken boards because load_sernum_ethaddr()
> is no longer called but the new init code is not installed yet.

umm, are you sure ?  the arm port is nicer than the ppc port because there is 
only one board that uses load_sernum_ethaddr().  so in 1 change, i dropped the 
call to load_sernum_ethaddr() and had the board move to misc_init_r().  i see 
no breakage in this change.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/174fa655/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-16 22:57   ` Wolfgang Denk
@ 2009-02-17  0:05     ` Mike Frysinger
  2009-02-17  0:16       ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:05 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 17:57:22 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > The environment is the canonical storage location of the mac address, so
> > we're killing off the global data location and moving everything to
> > querying the env directly.
> >
> > Move all the work of load_sernum_ethaddr() into a local load_ethaddr()
> > func and call that from misc_init_r().  We leave load_sernum_ethaddr()
> > as a stub so that it can be removed from all places in a later commit.
> >
> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> > CC: Stefan Roese <sr@denx.de>
> > CC: Ben Warren <biggerbadderben@gmail.com>
>
> ...
>
> > +void load_sernum_ethaddr (void)
> > +{
> > +}
> > +
>
> See previous comments - please do not add dead code just to remove it
> later.

your previous comment doesnt apply to these later ones.  the first change is 
for arm-only.  the later changes are for ppc.  it isnt dead code because the 
function is still called by common ppc code.  just like i outlined in the 
summary for this patchset.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/5321d2a4/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage
  2009-02-16 22:38   ` Wolfgang Denk
@ 2009-02-17  0:12     ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:12 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 17:38:54 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > +Here are the places where MAC addresses might be stored:
> > +
> > + - board-specific location (eeprom, dedicated flash, ...)
> > +	Note: only used when mandatory due to hardware design etc...
> > +
> > + - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR)
> > +	Note: this is the preferred way to permanently store MAC addresses
> > +
> > + - ethernet data (struct eth_device -> enetaddr)
> > +	Note: these are temporary copies of the MAC address which exist only
> > +	      after the respective init steps have run and only to make usage
> > +	      in other places easier (to avoid constant env lookup/parsing)
>
>     - struct bd_info and/or device tree
>         Note: these are temporary copies of the MAC address only foir
> 	the purpose to pass this information to an OS kernel we are
> 	about to boot
>
> > +The common environment code will take care of passing environment
> > changes to +the global data.  This happens automatically whenever
> > setenv() updates the +relevant ethaddr variables.
>
> Didn't we just remove the MAC address information from the global
> data?
>
> > +Any other common code that wishes to access the MAC address should then
> > query +the global data directly.  No one should be looking in the
> > environment for any +addresses.
>
> Is this still valid?

erm, i updated the file in places i remembered, but didnt give it a complete 
top-to-bottom look over after the last discussion.  ive fixed up the things 
you pointed out, thanks.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/d7a34961/attachment-0001.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-17  0:00     ` Mike Frysinger
@ 2009-02-17  0:13       ` Wolfgang Denk
  2009-02-17  0:20         ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-17  0:13 UTC (permalink / raw)
  To: u-boot

Dear Mike,

In message <200902161900.49096.vapier@gentoo.org> you wrote:
>
> > Hm... Linux has a printk() format specifier for MAC addresses. Sounds
> > like a clever idea to me. Maybe we should borrow that code?
>
> it does eh ?  that certainly sounds a lot better than str_enetaddr() as every 
> place i changed to use it was in a printf() string.  where in the kernel is 
> that code ?  i looked in lib/vsprintf.c but couldnt find it.

But it is in lib/vsprintf.c:

 ...
 644 /*
 645  * Show a '%p' thing.  A kernel extension is that the '%p' is followed
 646  * by an extra set of alphanumeric characters that are extended format
 647  * specifiers.
 648  *
 649  * Right now we handle:
 650  *
 651  * - 'F' For symbolic function descriptor pointers
 652  * - 'S' For symbolic direct pointers
 653  * - 'R' For a struct resource pointer, it prints the range of
 654  *       addresses (not the name nor the flags)
 655  * - 'M' For a 6-byte MAC address, it prints the address in the
 656  *       usual colon-separated hex notation
 657  * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way (dot-separated
 658  *       decimal for v4 and colon separated network-order 16 bit hex for v6)
 659  * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is
 660  *       currently the same
 ...

So it's actually printk("%pM", ...);

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: wd at denx.de
To be sure of hitting the target, shoot first and, whatever you  hit,
call it the target.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-17  0:05     ` Mike Frysinger
@ 2009-02-17  0:16       ` Wolfgang Denk
  2009-02-17  0:22         ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-17  0:16 UTC (permalink / raw)
  To: u-boot

Dear Mike,

In message <200902161905.12952.vapier@gentoo.org> you wrote:
>
> > > +void load_sernum_ethaddr (void)
> > > +{
> > > +}
> > > +
> >
> > See previous comments - please do not add dead code just to remove it
> > later.
>
> your previous comment doesnt apply to these later ones.  the first change is 
> for arm-only.  the later changes are for ppc.  it isnt dead code because the 
> function is still called by common ppc code.  just like i outlined in the 
> summary for this patchset.

Well, there is a very small number of boards. Why cannot we have this
change in one step, in one commit? Adding empty functions just to
remove them later seems sub-optimal to me.

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: wd at denx.de
The human race has one really effective weapon, and that is laughter.
                                                         - Mark Twain

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-16 23:13                       ` Wolfgang Denk
@ 2009-02-17  0:18                         ` Mike Frysinger
  2009-02-17  0:27                           ` Wolfgang Denk
  2009-02-17  1:49                           ` Kim Phillips
  0 siblings, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:18 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 18:13:25 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > > And even renaming is BAD as it breaks compatibility with the Linux
> > > kernel.  It's bad enough that we have a binary data structure as a
> > > critical interface, but suing different variable names for the same
> > > fields would make it definitely worse.
> >
> > that doesnt make any sense at all.  the kernel isnt passed the structure
> > as seen in the C language, it gets passed a binary blob.  how the kernel
> > chooses to interpret it is up to the kernel.
>
> And how do you check for problems? At least initially by comparing
> the source code. Why making this more difficult than necessary?

yes, comparing the linux source and the u-boot source would be marginally more 
difficult.  but as you've highlighted many times, no new code should be using 
these fields, so the likely hood of people having to do that is pretty low 
imo.  the flip side of what i wrote to Scott is that people are actively 
porting code from older u-boot versions (how often do we see people saying 
that using u-boot-<some old version> isnt working) and if the field isnt 
renamed, things will appear to "just work".  so there is no way for them to 
know that they need to fix their code which means they wont.  otherwise, 
people hitting a build failure will know immediately that they need to update 
something.

again, generally i could care less because this is ppc code, but considering 
how many abusers we've had in common network drivers, people testing drivers 
on ppc will not notice this issue and instead, it'll make every other arch 
maintainers' life annoying.

perhaps if u-boot looked at importing and extending the check patch script 
from the kernel, then i would worry a lot less as we could make usage of this 
field a failure.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/d70cf74c/attachment.pgp 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-17  0:13       ` Wolfgang Denk
@ 2009-02-17  0:20         ` Mike Frysinger
  2009-02-17  0:26           ` Scott Wood
  2009-02-17  0:29           ` Wolfgang Denk
  0 siblings, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:20 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 19:13:31 Wolfgang Denk wrote:
> Dear Mike,
>
> In message <200902161900.49096.vapier@gentoo.org> you wrote:
> > > Hm... Linux has a printk() format specifier for MAC addresses. Sounds
> > > like a clever idea to me. Maybe we should borrow that code?
> >
> > it does eh ?  that certainly sounds a lot better than str_enetaddr() as
> > every place i changed to use it was in a printf() string.  where in the
> > kernel is that code ?  i looked in lib/vsprintf.c but couldnt find it.
>
> But it is in lib/vsprintf.c:

apparently it's new to 2.6.29 ... i'm actively working/looking at 2.6.28.x 
which doesnt have 'M'.

>  ...
>  644 /*
>  645  * Show a '%p' thing.  A kernel extension is that the '%p' is followed
>  646  * by an extra set of alphanumeric characters that are extended format
>  647  * specifiers.
>  648  *
>  649  * Right now we handle:
>  650  *
>  651  * - 'F' For symbolic function descriptor pointers
>  652  * - 'S' For symbolic direct pointers
>  653  * - 'R' For a struct resource pointer, it prints the range of
>  654  *       addresses (not the name nor the flags)
>  655  * - 'M' For a 6-byte MAC address, it prints the address in the
>  656  *       usual colon-separated hex notation
>  657  * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way
> (dot-separated 658  *       decimal for v4 and colon separated
> network-order 16 bit hex for v6) 659  * - 'i' [46] for 'raw' IPv4/IPv6
> addresses, IPv6 omits the colons, IPv4 is 660  *       currently the same
>  ...
>
> So it's actually printk("%pM", ...);

so do you want to go the %pM route (to make u-boot/linux code sharing easier) 
or move over only %M ?
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-17  0:16       ` Wolfgang Denk
@ 2009-02-17  0:22         ` Mike Frysinger
  2009-02-17  0:31           ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:22 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 19:16:13 Wolfgang Denk wrote:
> In message Mike wrote:
> > > > +void load_sernum_ethaddr (void)
> > > > +{
> > > > +}
> > > > +
> > >
> > > See previous comments - please do not add dead code just to remove it
> > > later.
> >
> > your previous comment doesnt apply to these later ones.  the first change
> > is for arm-only.  the later changes are for ppc.  it isnt dead code
> > because the function is still called by common ppc code.  just like i
> > outlined in the summary for this patchset.
>
> Well, there is a very small number of boards. Why cannot we have this
> change in one step, in one commit? Adding empty functions just to
> remove them later seems sub-optimal to me.

in my mind, what i did is more logical.  i'll do whatever way you want though.  
so just explicitly state "squash those changes into one even though they touch 
a bunch of different places" and i'll happily do it.
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-17  0:20         ` Mike Frysinger
@ 2009-02-17  0:26           ` Scott Wood
  2009-02-17  0:29           ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Scott Wood @ 2009-02-17  0:26 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> so do you want to go the %pM route (to make u-boot/linux code sharing easier) 
> or move over only %M ?

The latter would require turning off GCC's format checking.

-Scott

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-17  0:18                         ` Mike Frysinger
@ 2009-02-17  0:27                           ` Wolfgang Denk
  2009-02-17  1:49                           ` Kim Phillips
  1 sibling, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-17  0:27 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161918.21292.vapier@gentoo.org> you wrote:
>
> perhaps if u-boot looked at importing and extending the check patch script
> from the kernel, then i would worry a lot less as we could make usage of this 
> field a failure.

Well, maybe your words fall on some fertile ground, and some voluteer
enters the scene? He would be definitely welcome...

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: wd at denx.de
Computers are not intelligent.  They only think they are.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-17  0:20         ` Mike Frysinger
  2009-02-17  0:26           ` Scott Wood
@ 2009-02-17  0:29           ` Wolfgang Denk
  2009-02-17  0:37             ` Mike Frysinger
  1 sibling, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-17  0:29 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161920.39745.vapier@gentoo.org> you wrote:
>
> apparently it's new to 2.6.29 ... i'm actively working/looking at 2.6.28.x 
> which doesnt have 'M'.

Eventually that was triggered from our discussion here :-)

> > So it's actually printk("%pM", ...);
> 
> so do you want to go the %pM route (to make u-boot/linux code sharing easier) 
> or move over only %M ?

I don't really care, but for the sake of code compatibility we
probably should use Linux style.

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: wd at denx.de
If it happens once, it's a bug.
If it happens twice, it's a feature.
If it happens more than twice, it's a design philosophy.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-17  0:22         ` Mike Frysinger
@ 2009-02-17  0:31           ` Wolfgang Denk
  2009-02-17 13:42             ` Stefan Roese
  0 siblings, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-17  0:31 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161922.44211.vapier@gentoo.org> you wrote:
>
> > Well, there is a very small number of boards. Why cannot we have this
> > change in one step, in one commit? Adding empty functions just to
> > remove them later seems sub-optimal to me.
> 
> in my mind, what i did is more logical.  i'll do whatever way you want though.  
> so just explicitly state "squash those changes into one even though they touch 
> a bunch of different places" and i'll happily do it.

Hm... maybe somebody else comments?

Stefan, Ben?

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: wd at denx.de
Sometimes a feeling is all we humans have to go on.
	-- Kirk, "A Taste of Armageddon", stardate 3193.9

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-17  0:29           ` Wolfgang Denk
@ 2009-02-17  0:37             ` Mike Frysinger
  2009-02-17  7:31               ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  0:37 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 19:29:22 Wolfgang Denk wrote:
> In message Mike Frysinger you wrote:
> > apparently it's new to 2.6.29 ... i'm actively working/looking at
> > 2.6.28.x which doesnt have 'M'.
>
> Eventually that was triggered from our discussion here :-)
>
> > > So it's actually printk("%pM", ...);
> >
> > so do you want to go the %pM route (to make u-boot/linux code sharing
> > easier) or move over only %M ?
>
> I don't really care, but for the sake of code compatibility we
> probably should use Linux style.

ok ... it'll take me a bit to familiarize myself with the u-boot stdio code.  
then i'll send out the updated patch series (assuming all goes well).
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-17  0:18                         ` Mike Frysinger
  2009-02-17  0:27                           ` Wolfgang Denk
@ 2009-02-17  1:49                           ` Kim Phillips
  2009-02-17  3:24                             ` Mike Frysinger
  1 sibling, 1 reply; 84+ messages in thread
From: Kim Phillips @ 2009-02-17  1:49 UTC (permalink / raw)
  To: u-boot

On Mon, 16 Feb 2009 19:18:19 -0500
Mike Frysinger <vapier@gentoo.org> wrote:

> renamed, things will appear to "just work".  so there is no way for them to 
> know that they need to fix their code which means they wont.  otherwise, 
> people hitting a build failure will know immediately that they need to update 
> something.

there's also #warning for this type of situation, but I agree with
adding glaring comments in the code.

Kim

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches
  2009-02-17  1:49                           ` Kim Phillips
@ 2009-02-17  3:24                             ` Mike Frysinger
  0 siblings, 0 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-17  3:24 UTC (permalink / raw)
  To: u-boot

On Monday 16 February 2009 20:49:00 Kim Phillips wrote:
> Mike Frysinger <vapier@gentoo.org> wrote:
> > renamed, things will appear to "just work".  so there is no way for them
> > to know that they need to fix their code which means they wont. 
> > otherwise, people hitting a build failure will know immediately that they
> > need to update something.
>
> there's also #warning for this type of situation, but I agree with
> adding glaring comments in the code.

#warning's wont help as there's no way to take it onto a member of a struct 
(unless there's something i'm not aware of), plus the common ppc code 
explicitly set it all the time and we dont want to have that trigger a warning
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's
  2009-02-17  0:37             ` Mike Frysinger
@ 2009-02-17  7:31               ` Wolfgang Denk
  0 siblings, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-17  7:31 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902161937.36039.vapier@gentoo.org> you wrote:
>
> ok ... it'll take me a bit to familiarize myself with the u-boot stdio code.  
> then i'll send out the updated patch series (assuming all goes well).

Excellent. I really appreaciate all the work you're doing here.

U-Boot's printf implementation was taken directly from Linux kernel
code (but a long, long time ago), so that should be a straightforward
task).

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: wd at denx.de
How many QA engineers does it take to screw in a lightbulb? 3:  1  to
screw it in and 2 to say "I told you so" when it doesn't work.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-17  0:31           ` Wolfgang Denk
@ 2009-02-17 13:42             ` Stefan Roese
  2009-02-18 22:17               ` Mike Frysinger
  0 siblings, 1 reply; 84+ messages in thread
From: Stefan Roese @ 2009-02-17 13:42 UTC (permalink / raw)
  To: u-boot

On Tuesday 17 February 2009, Wolfgang Denk wrote:
> > > Well, there is a very small number of boards. Why cannot we have this
> > > change in one step, in one commit? Adding empty functions just to
> > > remove them later seems sub-optimal to me.
> >
> > in my mind, what i did is more logical.  i'll do whatever way you want
> > though. so just explicitly state "squash those changes into one even
> > though they touch a bunch of different places" and i'll happily do it.
>
> Hm... maybe somebody else comments?
>
> Stefan, Ben?

Personally I would prefer this "squashed" patch version as well. If possible 
in a "git-bisectable" version.

Thanks for all your effort here. Really appreciated.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-17 13:42             ` Stefan Roese
@ 2009-02-18 22:17               ` Mike Frysinger
  2009-02-18 22:36                 ` Wolfgang Denk
  0 siblings, 1 reply; 84+ messages in thread
From: Mike Frysinger @ 2009-02-18 22:17 UTC (permalink / raw)
  To: u-boot

On Tuesday 17 February 2009 08:42:01 Stefan Roese wrote:
> On Tuesday 17 February 2009, Wolfgang Denk wrote:
> > > > Well, there is a very small number of boards. Why cannot we have this
> > > > change in one step, in one commit? Adding empty functions just to
> > > > remove them later seems sub-optimal to me.
> > >
> > > in my mind, what i did is more logical.  i'll do whatever way you want
> > > though. so just explicitly state "squash those changes into one even
> > > though they touch a bunch of different places" and i'll happily do it.
> >
> > Hm... maybe somebody else comments?
> >
> > Stefan, Ben?
>
> Personally I would prefer this "squashed" patch version as well. If
> possible in a "git-bisectable" version.

it would be bisectable because then there would be only one change:
 - every board would move load_sernum_ethaddr() to board init (as well as any 
side effects that the change requires)
 - the common ppc code would stop calling load_sernum_ethaddr()

i think this is the only outstanding issue for the patchset before Ben merges 
it into whatever testing tree he has ...
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-18 22:17               ` Mike Frysinger
@ 2009-02-18 22:36                 ` Wolfgang Denk
  2009-02-18 22:41                   ` Ben Warren
  2009-02-18 22:49                   ` Mike Frysinger
  0 siblings, 2 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-18 22:36 UTC (permalink / raw)
  To: u-boot

Dear Mike, dear Ben,

in message <200902181717.12756.vapier@gentoo.org> you wrote:
>
> i think this is the only outstanding issue for the patchset before Ben merges 
> it into whatever testing tree he has ...

I agree that this is the last issue at the moment.

This is a pretty big change that affects much  more  than  networking
code  (even  though  the  cause  of  the  changes  is network support
related). So I tend to pull this into mainline quickly.

Ben:

if you agree, please just ACK the patches, and I will pull them into
the next branch (which I will create as soon as 2009-03-rc1 is out or
the new patch series gets posted, whatever comes earlier).

Mike, I guess this is OK with you, too?

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: wd at denx.de
In general, if you think something isn't in Perl, try it out, because
it usually is :-) - Larry Wall in <1991Jul31.174523.9447@netlabs.com>

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-18 22:36                 ` Wolfgang Denk
@ 2009-02-18 22:41                   ` Ben Warren
  2009-02-18 22:49                   ` Mike Frysinger
  1 sibling, 0 replies; 84+ messages in thread
From: Ben Warren @ 2009-02-18 22:41 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
> Dear Mike, dear Ben,
>
> in message <200902181717.12756.vapier@gentoo.org> you wrote:
>   
>> i think this is the only outstanding issue for the patchset before Ben merges 
>> it into whatever testing tree he has ...
>>     
>
> I agree that this is the last issue at the moment.
>
> This is a pretty big change that affects much  more  than  networking
> code  (even  though  the  cause  of  the  changes  is network support
> related). So I tend to pull this into mainline quickly.
>
> Ben:
>
> if you agree, please just ACK the patches, and I will pull them into
> the next branch (which I will create as soon as 2009-03-rc1 is out or
> the new patch series gets posted, whatever comes earlier).
>
>   
Yes, this is good.  Your 'next' will get much more exposure than mine.
> Mike, I guess this is OK with you, too?
>
> Best regards,
>
> Wolfgang Denk
>
>   

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-18 22:36                 ` Wolfgang Denk
  2009-02-18 22:41                   ` Ben Warren
@ 2009-02-18 22:49                   ` Mike Frysinger
  2009-02-18 22:54                     ` Wolfgang Denk
  2009-02-19  0:06                     ` Wolfgang Denk
  1 sibling, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-18 22:49 UTC (permalink / raw)
  To: u-boot

On Wednesday 18 February 2009 17:36:04 Wolfgang Denk wrote:
> in message Mike wrote:
> > i think this is the only outstanding issue for the patchset before Ben
> > merges it into whatever testing tree he has ...
>
> I agree that this is the last issue at the moment.

btw, i'm waiting for an explicit "go squash them" from you ;)

> This is a pretty big change that affects much  more  than  networking
> code  (even  though  the  cause  of  the  changes  is network support
> related). So I tend to pull this into mainline quickly.
>
> Ben:
>
> if you agree, please just ACK the patches, and I will pull them into
> the next branch (which I will create as soon as 2009-03-rc1 is out or
> the new patch series gets posted, whatever comes earlier).
>
> Mike, I guess this is OK with you, too?

yeah, that's fine with me
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-18 22:49                   ` Mike Frysinger
@ 2009-02-18 22:54                     ` Wolfgang Denk
  2009-02-19  0:06                     ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-18 22:54 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902181749.33146.vapier@gentoo.org> you wrote:
>
> > I agree that this is the last issue at the moment.
> 
> btw, i'm waiting for an explicit "go squash them" from you ;)

I see: go squash them, please!

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: wd at denx.de
Let the programmers be many and the managers few -- then all will  be
productive.               -- Geoffrey James, "The Tao of Programming"

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-18 22:49                   ` Mike Frysinger
  2009-02-18 22:54                     ` Wolfgang Denk
@ 2009-02-19  0:06                     ` Wolfgang Denk
  2009-02-19  1:45                       ` Mike Frysinger
  1 sibling, 1 reply; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-19  0:06 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902181749.33146.vapier@gentoo.org> you wrote:
>
> > if you agree, please just ACK the patches, and I will pull them into
> > the next branch (which I will create as soon as 2009-03-rc1 is out or
> > the new patch series gets posted, whatever comes earlier).
> >
> > Mike, I guess this is OK with you, too?
> 
> yeah, that's fine with me

"next" branch is ready and waiting :-)

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: wd at denx.de
We're all sorry for the other guy when he loses his job to a machine.
But when it comes to your job -- that's different. And it always will
be different.
	-- McCoy, "The Ultimate Computer", stardate 4729.4

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-19  0:06                     ` Wolfgang Denk
@ 2009-02-19  1:45                       ` Mike Frysinger
  2009-02-19 12:12                         ` Wolfgang Denk
  2009-02-19 13:08                         ` Wolfgang Denk
  0 siblings, 2 replies; 84+ messages in thread
From: Mike Frysinger @ 2009-02-19  1:45 UTC (permalink / raw)
  To: u-boot

On Wednesday 18 February 2009 19:06:04 Wolfgang Denk wrote:
> In message Mike Frysinger wrote:
> > > if you agree, please just ACK the patches, and I will pull them into
> > > the next branch (which I will create as soon as 2009-03-rc1 is out or
> > > the new patch series gets posted, whatever comes earlier).
> > >
> > > Mike, I guess this is OK with you, too?
> >
> > yeah, that's fine with me
>
> "next" branch is ready and waiting :-)

ive pushed up to my macaddr branch.  the changes are:
 - rebased against latest master mainline master
 - expanded vprintf() changelog a bit
 - squashed the ppc load_sernum_ethaddr() changes into 1 commit
 - fixed the return value in eth_getenv_enetaddr()
 - fixed bugs in the net cdp code pointed out in 2nd patch series
-mike

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-19  1:45                       ` Mike Frysinger
@ 2009-02-19 12:12                         ` Wolfgang Denk
  2009-02-19 12:31                           ` Jean-Christophe PLAGNIOL-VILLARD
  2009-02-19 12:52                           ` Wolfgang Denk
  2009-02-19 13:08                         ` Wolfgang Denk
  1 sibling, 2 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-19 12:12 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902182046.01290.vapier@gentoo.org> you wrote:
>
> ive pushed up to my macaddr branch.  the changes are:
>  - rebased against latest master mainline master
>  - expanded vprintf() changelog a bit
>  - squashed the ppc load_sernum_ethaddr() changes into 1 commit
>  - fixed the return value in eth_getenv_enetaddr()
>  - fixed bugs in the net cdp code pointed out in 2nd patch series

Thanks.  Unfortunately the first patch in the series (the printf
extension) breaks some board - I just did a small test and got this:

Configuring for TQM860L board...
/home/wd/git/u-boot/next/board/tqc/tqm8xx/u-boot.lds:145 cannot move
location counter backwards (from 40008088 to 40008000)
make: *** [u-boot] Error 1
ppc_8xx-size: './u-boot': No such file


Mike - do you want to fix the loader script, or do you want the board
maintainer to do that (i. e. me) ?

I think we should do these changes BEFORE appplying your patch
series (to avoid bisect issues), what do you think?


Note (especially to Jean-Christophe who asked): 

I measured the size impact of the printf changes; a short scan on
seven PowerPC boards showed an average size increase of 1.6 kB:

Board		Diff	old	new
TQM8260		1168 : 189520 190688
TQM5200		1152 : 690468 691620
ads5121		1168 : 264816 265984
ocotea		1256 : 313444 314700
sequoia		1256 : 703404 704660
MPC8572DS	1236 : 487457 488693
MPC8641HPCN	4064 : 463916 467980
		AVRG: 1614


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: wd at denx.de
1st Old Man:  Gee, its windy today.
2nd Old Man:  No it's not... it's Thursday.
3rd Old Man:  Yeh, me too.  Let's go for a beer.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-19 12:12                         ` Wolfgang Denk
@ 2009-02-19 12:31                           ` Jean-Christophe PLAGNIOL-VILLARD
  2009-02-19 12:52                           ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-02-19 12:31 UTC (permalink / raw)
  To: u-boot

> 
> Note (especially to Jean-Christophe who asked): 
> 
> I measured the size impact of the printf changes; a short scan on
> seven PowerPC boards showed an average size increase of 1.6 kB:
> 
> Board		Diff	old	new
> TQM8260		1168 : 189520 190688
> TQM5200		1152 : 690468 691620
> ads5121		1168 : 264816 265984
> ocotea		1256 : 313444 314700
> sequoia		1256 : 703404 704660
> MPC8572DS	1236 : 487457 488693
> MPC8641HPCN	4064 : 463916 467980
> 		AVRG: 1614
> 
Tks,
IMHO improve the printf is important but may need to plan to clean up or
improve other part of U-Boot to allow peolple to reduce its size.
Especially the NOR driver that does not allow to enable/disable vendor support
as the kernel

Best Regards,
J.

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-19 12:12                         ` Wolfgang Denk
  2009-02-19 12:31                           ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-02-19 12:52                           ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-19 12:52 UTC (permalink / raw)
  To: u-boot

Dear Mile,

In message <20090219121234.4669E832E43F@gemini.denx.de> I wrote:
> 
> Thanks.  Unfortunately the first patch in the series (the printf
> extension) breaks some board - I just did a small test and got this:
> 
> Configuring for TQM860L board...
> /home/wd/git/u-boot/next/board/tqc/tqm8xx/u-boot.lds:145 cannot move
> location counter backwards (from 40008088 to 40008000)
> make: *** [u-boot] Error 1
> ppc_8xx-size: './u-boot': No such file
> 
> 
> Mike - do you want to fix the loader script, or do you want the board
> maintainer to do that (i. e. me) ?

Don't bother. Patch following.

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: wd at denx.de
"The net result is a system that is not only binary  compatible  with
4.3  BSD, but is even bug for bug compatible in almost all features."
- Avadit  Tevanian,  Jr.,  "Architecture-Independent  Virtual  Memory
Management  for  Parallel  and  Distributed  Environments:  The  Mach
Approach"

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
  2009-02-19  1:45                       ` Mike Frysinger
  2009-02-19 12:12                         ` Wolfgang Denk
@ 2009-02-19 13:08                         ` Wolfgang Denk
  1 sibling, 0 replies; 84+ messages in thread
From: Wolfgang Denk @ 2009-02-19 13:08 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

In message <200902182046.01290.vapier@gentoo.org> you wrote:
> On Wednesday 18 February 2009 19:06:04 Wolfgang Denk wrote:
> > In message Mike Frysinger wrote:
> > > > if you agree, please just ACK the patches, and I will pull them into
> > > > the next branch (which I will create as soon as 2009-03-rc1 is out or
> > > > the new patch series gets posted, whatever comes earlier).
> > > >
> > > > Mike, I guess this is OK with you, too?
> > >
> > > yeah, that's fine with me
> >
> > "next" branch is ready and waiting :-)
> 
> ive pushed up to my macaddr branch.  the changes are:
>  - rebased against latest master mainline master
>  - expanded vprintf() changelog a bit
>  - squashed the ppc load_sernum_ethaddr() changes into 1 commit
>  - fixed the return value in eth_getenv_enetaddr()
>  - fixed bugs in the net cdp code pointed out in 2nd patch series

Applied to "next" branch. Thanks for all the work, and for your
patience.

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: wd at denx.de
Randal said it would be tough to do in sed. He didn't say  he  didn't
understand  sed.  Randal  understands sed quite well. Which is why he
uses Perl. :-)         - Larry Wall in <7874@jpl-devvax.JPL.NASA.GOV>

^ permalink raw reply	[flat|nested] 84+ messages in thread

end of thread, other threads:[~2009-02-19 13:08 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-14  7:22 [U-Boot] [PATCH 00/27] standardize mac address handling in u-boot Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 01/27] net: new utility functions for working with enetaddr's Mike Frysinger
2009-02-16 22:28   ` Wolfgang Denk
2009-02-17  0:00     ` Mike Frysinger
2009-02-17  0:13       ` Wolfgang Denk
2009-02-17  0:20         ` Mike Frysinger
2009-02-17  0:26           ` Scott Wood
2009-02-17  0:29           ` Wolfgang Denk
2009-02-17  0:37             ` Mike Frysinger
2009-02-17  7:31               ` Wolfgang Denk
2009-02-14  7:22 ` [U-Boot] [PATCH 02/27] doc/README.enetaddr: document proper MAC usage Mike Frysinger
2009-02-16 22:38   ` Wolfgang Denk
2009-02-17  0:12     ` Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 03/27] Blackfin: bfin_mac: force boards to setup the MAC themselves Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 04/27] net: get mac address from environment and use eth util funcs Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 05/27] bdinfo: get mac address from environment Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 06/27] bootvx: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 07/27] lynxkdi: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 08/27] nvedit: do not update global bi_enetaddr and do not call eth_set_enetaddr() Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 09/27] AmigaOneG3SE/enet: get mac address from environment Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 10/27] boards: " Mike Frysinger
2009-02-16 22:46   ` Wolfgang Denk
2009-02-16 23:55     ` Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 11/27] drivers/net/: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 12/27] bcm570x: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 13/27] cs8900: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 14/27] sh_eth: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 15/27] lan91c96/smc91111/smc911x: " Mike Frysinger
2009-02-14  7:22 ` [U-Boot] [PATCH 16/27] cpu/: " Mike Frysinger
2009-02-16 22:52   ` Wolfgang Denk
2009-02-16 23:56     ` Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 17/27] npe: " Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 18/27] lib_*/board.c: do not initialize bi_enet*addr in global data Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 19/27] nx823: get mac address from environment Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 20/27] arm: " Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 21/27] cmc_pu2: " Mike Frysinger
2009-02-16 22:56   ` Wolfgang Denk
2009-02-17  0:03     ` Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 22/27] pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init Mike Frysinger
2009-02-16 22:57   ` Wolfgang Denk
2009-02-17  0:05     ` Mike Frysinger
2009-02-17  0:16       ` Wolfgang Denk
2009-02-17  0:22         ` Mike Frysinger
2009-02-17  0:31           ` Wolfgang Denk
2009-02-17 13:42             ` Stefan Roese
2009-02-18 22:17               ` Mike Frysinger
2009-02-18 22:36                 ` Wolfgang Denk
2009-02-18 22:41                   ` Ben Warren
2009-02-18 22:49                   ` Mike Frysinger
2009-02-18 22:54                     ` Wolfgang Denk
2009-02-19  0:06                     ` Wolfgang Denk
2009-02-19  1:45                       ` Mike Frysinger
2009-02-19 12:12                         ` Wolfgang Denk
2009-02-19 12:31                           ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-19 12:52                           ` Wolfgang Denk
2009-02-19 13:08                         ` Wolfgang Denk
2009-02-14  7:23 ` [U-Boot] [PATCH 23/27] kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr() Mike Frysinger
2009-02-16 22:58   ` Wolfgang Denk
2009-02-14  7:23 ` [U-Boot] [PATCH 24/27] tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() Mike Frysinger
2009-02-16 22:58   ` Wolfgang Denk
2009-02-14  7:23 ` [U-Boot] [PATCH 25/27] ppc: do not initialize bi_enet*addr in global data Mike Frysinger
2009-02-14  7:23 ` [U-Boot] [PATCH 26/27] drop now unused load_sernum_ethaddr() function Mike Frysinger
2009-02-14  9:22   ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-14 18:03     ` Mike Frysinger
2009-02-16 22:58   ` Wolfgang Denk
2009-02-14  7:23 ` [U-Boot] [PATCH 27/27] remove bi_enet*addr from global data for all arches Mike Frysinger
2009-02-16 18:16   ` Scott Wood
2009-02-16 18:57     ` Mike Frysinger
2009-02-16 19:00       ` Scott Wood
2009-02-16 19:29         ` Mike Frysinger
2009-02-16 19:47           ` Wolfgang Denk
2009-02-16 19:59             ` Mike Frysinger
2009-02-16 20:14               ` Wolfgang Denk
2009-02-16 20:49                 ` Mike Frysinger
2009-02-16 20:54                   ` Scott Wood
2009-02-16 21:13                     ` Mike Frysinger
2009-02-16 21:03                   ` Wolfgang Denk
2009-02-16 21:18                     ` Mike Frysinger
2009-02-16 23:13                       ` Wolfgang Denk
2009-02-17  0:18                         ` Mike Frysinger
2009-02-17  0:27                           ` Wolfgang Denk
2009-02-17  1:49                           ` Kim Phillips
2009-02-17  3:24                             ` Mike Frysinger
2009-02-16 19:24       ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.