Skip to contentSkip to conversation

ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

PATCH New Bernhard Kaindl 4 participants 9 messages Oct 16, 2011 – Dec 9, 2011 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

ne2000 wasn't converted to CONFIG_NET_MULTI when the non-multi support was dropped, so boards using it (qemu-mips, shmin, r7780mp) failed to compile for multiple definition of eth_rx() and friends due to old ne2000_base.c.

Changes:

In drivers/net/ne2000_base.c:

- Convert the driver to use a new probe function which calls eth_register():
- move probing / MAC addr code from eth_init to new ne2000_initialize()
- cleanup the moved code to use eth_setenv_enetaddr()
- Rename eth_init, eth_rx, eth_send and eth_halt to ne2k_* and use new calls

qemu-mips, shmin, r7780mp:
- Call the new ne2000_initialize() from board_eth_init() of the boards.

Cleanups in drivers/net/ne2000_base.c:

- Use NE2000_RX_BUFFER_SIZE, defined to 2000 instead of a 2000 size constant.
- dp83902a_init():
- Remove check for dp->base (nic.base): It is always assinged in probe func
- Extend #ifdef NE2000_BASIC_INIT to whole function: The function does not have any useful code if NE2000_BASIC_INIT is not defined anymore.
- Change printf of ESA MAC to debug PRINTK: Was always overridden(= not used)
- In case somebody wants to use the ESA mac, add ifdef'ed memcpy to use it.
- Fix gcc warnings in two debug printf calls

- Tested using qemu-mips board,
- Tested the two renesas / sh boards r7780mp and shmin to compile again, and should work.

---
 board/qemu-mips/qemu-mips.c     |    6 ++
 board/renesas/r7780mp/r7780mp.c |    3 +-
 board/shmin/shmin.c             |    5 ++
 drivers/net/ne2000_base.c       |  135 +++++++++++++++++++--------------------
 include/netdev.h                |    1 +
 5 files changed, 81 insertions(+), 69 deletions(-)
board/qemu-mips/qemu-mips.c +5 -0
index 7a69a00..e0372a6 100644
@@ -87,3 +87,8 @@ int misc_init_r(void)
 	set_io_port_base(0);
 	return 0;
 }
+
+int board_eth_init(bd_t *bis)
+{
+	return ne2000_initialize();
+}
board/renesas/r7780mp/r7780mp.c +2 -1
index 0b80099..004c67e 100644
@@ -81,5 +81,6 @@ void pci_init_board(void)
 
 int board_eth_init(bd_t *bis)
 {
-	return pci_eth_init(bis);
+	/* return >= 0 if a chip is found, the board's AX88796L is n2k-based */
+	return ne2000_initialize() + pci_eth_init(bis);
 }
board/shmin/shmin.c +5 -0
index 8742f10..9292af4 100644
@@ -55,6 +55,11 @@ int dram_init(void)
 	return 0;
 }
 
+int board_eth_init(bd_t *bis)
+{
+	return ne2000_initialize();
+}
+
 void led_set_state(unsigned short value)
 {
 
drivers/net/ne2000_base.c +67 -68

209 lines not on this page · raw message

include/netdev.h +1 -0
index 480453e..d13a5e2 100644
@@ -79,6 +79,7 @@ int mpc8220_fec_initialize(bd_t *bis);
 int mpc82xx_scc_enet_initialize(bd_t *bis);
 int mvgbe_initialize(bd_t *bis);
 int natsemi_initialize(bd_t *bis);
+int ne2000_initialize();
 int npe_initialize(bd_t *bis);
 int ns8382x_initialize(bd_t *bis);
 int pcnet_initialize(bd_t *bis);
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

Quoted 3 lines · On Sunday 16 October 2011 14:12:57 Bernhard Kaindl wrote:

ne2000 wasn't converted to CONFIG_NET_MULTI when the non-multi support was dropped, so boards using it (qemu-mips, shmin, r7780mp) failed to compile for multiple definition of eth_rx() and friends due to old ne2000_base.c.

ah i wrote a patch for this but forgot to post it :/

Quoted 3 lines

- Tested using qemu-mips board,
- Tested the two renesas / sh boards r7780mp and shmin to compile again, and should work.

but i couldn't test it, so this is even better

Quoted 9 lines
board/qemu-mips/qemu-mips.c +4 -0
 
+int board_eth_init(bd_t *bis)
+{
+	return ne2000_initialize();
+}

board/shmin/shmin.c int dram_init(void) · line 61

Quoted 5 lines
board/shmin/shmin.c +4 -0
 
+int board_eth_init(bd_t *bis)
+{
+	return ne2000_initialize();
+}

did you need to include netdev.h in this files for the new ne2000_initialize() prototype ?

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 722

Quoted 13 lines
drivers/net/ne2000_base.c +10 -0
 
+int ne2000_initialize(void)
+{
+	struct eth_device *dev;
+
+	nic.base = (u8 *) CONFIG_DRIVER_NE2000_BASE;
+	nic.data = nic.base + DP_DATA;
+	nic.tx_buf1 = START_PG;
+	nic.tx_buf2 = START_PG2;
+	nic.rx_buf_start = RX_START;
+	nic.rx_buf_end = RX_END;

this should be using dev->priv rather than a global "nic" data structure

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 728

Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	dev = calloc(sizeof(*dev), 1);
+	pbuf = malloc(NE2000_RX_BUFFER_SIZE);
+	if (dev == NULL || pbuf == NULL)
+		return -1;

if dev worked but pbuf failed, this leaks memory

also, you should return 0 here not -1

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 733

Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	if (!get_prom(dev->enetaddr, nic.base))
+		return -1;
+
+	dp83902a_init(dev);

these should probably be in the eth->init step and not here

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 735

Quoted 1 line
drivers/net/ne2000_base.c +1 -0
+	eth_setenv_enetaddr("ethaddr", dev->enetaddr);

NAK: implement eth->write_hwaddr, and the driver should only use dev->enetaddr rather than touching the env

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 746

Quoted 10 lines
drivers/net/ne2000_base.c +10 -0
+	/* For PCMCIA support: See doc/README.ne2000 on how to enable */
+#ifdef CONFIG_DRIVER_NE2000_CCR
+	{
+		vu_char *p = (vu_char *) CONFIG_DRIVER_NE2000_CCR;
+
+		PRINTK("CCR before is %x\n", *p);
+		*p = CONFIG_DRIVER_NE2000_VAL;
+		PRINTK("CCR after is %x\n", *p);
+	}
+#endif

i think this should be in ne2k_init

include/netdev.h

Quoted 4 lines
include/netdev.h +1 -0
 
+int ne2000_initialize();

needs to be "(void)"
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111016/cb39e5ac/attachment.pgp

#2 lore raw

PATCH 1/1 ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

Am 16.10.2011 21:39, schrieb Mike Frysinger:

Quoted 6 lines · On Sunday 16 October 2011 14:12:57 Bernhard Kaindl wrote:
Quoted 3 lines

ne2000 wasn't converted to CONFIG_NET_MULTI when the non-multi support was dropped, so boards using it (qemu-mips, shmin, r7780mp) failed to compile for multiple definition of eth_rx() and friends due to old ne2000_base.c.

ah i wrote a patch for this but forgot to post it :/

Argh, I feared you or somebody else might have done it too.

Quoted 5 lines
Quoted 3 lines

- Tested using qemu-mips board,
- Tested the two renesas / sh boards r7780mp and shmin to compile again, and should work.

but i couldn't test it, so this is even better

Be my guest (see doc/README.qemu_mips for everything you want to know):
ln -s u-boot.bin mips_bios.bin; qemu-system-mips -M mips -L . -nographic qemu-mips # dhcp

Quoted 10 lines
Quoted 10 lines
board/qemu-mips/qemu-mips.c +4 -0
 
+int board_eth_init(bd_t *bis)
+{
+	return ne2000_initialize();
+}
board/shmin/shmin.c +0 -0
Quoted 7 lines

board/shmin/shmin.c

Quoted 4 lines
board/shmin/shmin.c +4 -0
+int board_eth_init(bd_t *bis)
+{
+	return ne2000_initialize();
+}

did you need to include netdev.h in this files for the new ne2000_initialize() prototype ?

Thanks, need to add an #include in shmin.c.

Lets really turn on -Werror to once for all put an end to such things. Lazy maintainers can aways put a CFLAGS += Wno-error into their makefiles if they can't fix warnings in a given directory. At the very least, -Werror-implicit-function-declaration should be used. Both flags are supported by gcc-2.95.3 or older gcc.gnu.org says.

Quoted 15 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 722

Quoted 13 lines
drivers/net/ne2000_base.c +10 -0
 
+int ne2000_initialize(void)
+{
+	struct eth_device *dev;
+
+	nic.base = (u8 *) CONFIG_DRIVER_NE2000_BASE;
+	nic.data = nic.base + DP_DATA;
+	nic.tx_buf1 = START_PG;
+	nic.tx_buf2 = START_PG2;
+	nic.rx_buf_start = RX_START;
+	nic.rx_buf_end = RX_END;

this should be using dev->priv rather than a global "nic" data structure

Understand, but the 2/3 boards using it only have a single ne2k-based chip, and as no one actually uses the driver multi-card, I skipped these larger changes to make it multi-card and use dev->priv everywhere.

Quoted 6 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 728

Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	dev = calloc(sizeof(*dev), 1);
+	pbuf = malloc(NE2000_RX_BUFFER_SIZE);
+	if (dev == NULL || pbuf == NULL)
+		return -1;

if dev worked but pbuf failed, this leaks memory

If malloc fails here, either CONFIG_SYS_MALLOC_LEN is to small or malloc is broken. Three Ethernet drivers call hang() in this case, which is probably best in explaining to the developer who broke it.
I can replace that with "goto error" and give an error message on it like the other recently merged drivers do in this init situation.

Quoted 1 line

also, you should return 0 here not -1

The recently merged drivers (armada100 - heavvy reviewed and you and many others, the xilinx_axi_emac(acked by you) and many more return -1 on malloc error.

Quoted 7 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 733

Quoted 5 lines
drivers/net/ne2000_base.c +4 -0
+	if (!get_prom(dev->enetaddr, nic.base))
+		return -1;
+
+	dp83902a_init(dev);

these should probably be in the eth->init step and not here

At first sight, I thought the same and did it the same but then you get

Net: NE2000
Warning: failed to set MAC address

if you don't call eth_setenv_enetaddr("ethaddr", dev->enetaddr) with the dev->enetaddr retrieved by get_prom(), so this has to be put here.

The error "Warning: failed to set MAC address" is in this case caused by ethaddr not being set in env. See the comment to you NAK below.

There are limits to what we can put into eth->init, and if the board or card has the original MAC address stored in HW (not U-Boot env) like the NE2000, the driver has to read the MAC from the HW and set ethaddr in env before registering the card, see below:

Quoted 4 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 735

Quoted 1 line
drivers/net/ne2000_base.c +1 -0
+	eth_setenv_enetaddr("ethaddr", dev->enetaddr);

NAK: implement eth->write_hwaddr, and the driver should only use dev->enetaddr rather than touching the env

Wrong NAK: If ethaddr is not set in env, this "return -1" below triggers and no call to eth->write_hwaddr can be reached (below the return -1):

net/eth.c:

int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
int eth_number)

{
         unsigned char env_enetaddr[6];
         int ret = 0;

         if (!eth_getenv_enetaddr_by_index(base_name, eth_number,
                                                       env_enetaddr))
                 return -1;

The NE2000 has the MAC in its PROM/EEPROM, which has to be used for it, and the code above requires it to be set in the env as well or the error shown in the previous comment occurs.

Read the call to eth_write_hwaddr() in net/eth.c and what it does.

Quoted 4 lines
Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	/* For PCMCIA support: See doc/README.ne2000 on how to enable */
+#ifdef CONFIG_DRIVER_NE2000_CCR
+	{
+		vu_char *p = (vu_char *) CONFIG_DRIVER_NE2000_CCR;
Quoted 8 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 746

Quoted 6 lines
drivers/net/ne2000_base.c +6 -0
+
+		PRINTK("CCR before is %x\n", *p);
+		*p = CONFIG_DRIVER_NE2000_VAL;
+		PRINTK("CCR after is %x\n", *p);
+	}
+#endif

i think this should be in ne2k_init

It should not be ne2k_init but moved before calling get_prom() because it sets the PCMCIA card configuration register. No board still in mainline U-Boot uses an NE2000 in a PCMCIA slot, so this NE2000 in PCMCIA code could also be dropped in principle.

Quoted 6 lines

include/netdev.h

Quoted 4 lines
include/netdev.h +1 -0
 
+int ne2000_initialize();

needs to be "(void)"

Ack.

Quoted 1 line

-mike

Summary:

From this review, the needed changes to the patch to be done are:

- #include <netdev.h> in board/shmin/shmin.c to fix warning
- add "void" as argument to function prototype in include/netdev.h
- Move PCMCIA CCR init before get_prom() call or remove it (not used)

Bernhard

#3 lore raw

PATCH 1/1 ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

Quoted 5 lines · On Monday 17 October 2011 18:05:28 Bernhard Kaindl wrote:

Lets really turn on -Werror to once for all put an end to such things. Lazy maintainers can aways put a CFLAGS += Wno-error into their makefiles if they can't fix warnings in a given directory. At the very least, -Werror-implicit-function-declaration should be used. Both flags are supported by gcc-2.95.3 or older gcc.gnu.org says.

i don't think -Werror is feasible. there are way too many versions of gcc out there that we try to support from too many different vendors and too many architectures. warnings tend to come and go in between versions, and -Werror is just hell.

personally, i don't mind it to track local development of the latest tree, but it isn't something i'd inflict in general.

-Werror-implicit-function-declaration however sounds wonderful. and we don't have to worry about gcc versions as we have a cc-option helper:

	CFLAGS += $(call cc-option,-Werror-implicit-function-declaration)

care to send a patch ?

Quoted 16 lines
Quoted 15 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 722

Quoted 13 lines
drivers/net/ne2000_base.c +10 -0
 
+int ne2000_initialize(void)
+{
+	struct eth_device *dev;
+
+	nic.base = (u8 *) CONFIG_DRIVER_NE2000_BASE;
+	nic.data = nic.base + DP_DATA;
+	nic.tx_buf1 = START_PG;
+	nic.tx_buf2 = START_PG2;
+	nic.rx_buf_start = RX_START;
+	nic.rx_buf_end = RX_END;

this should be using dev->priv rather than a global "nic" data structure

Quoted 3 lines

Understand, but the 2/3 boards using it only have a single ne2k-based chip, and as no one actually uses the driver multi-card, I skipped these larger changes to make it multi-card and use dev->priv everywhere.

i'll let that slide since i broke the build ;). but i'd really like to see this fixed long term.

Quoted 7 lines
Quoted 6 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 728

Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	dev = calloc(sizeof(*dev), 1);
+	pbuf = malloc(NE2000_RX_BUFFER_SIZE);
+	if (dev == NULL || pbuf == NULL)
+		return -1;

if dev worked but pbuf failed, this leaks memory

Quoted 5 lines

If malloc fails here, either CONFIG_SYS_MALLOC_LEN is to small or malloc is broken. Three Ethernet drivers call hang() in this case, which is probably best in explaining to the developer who broke it.
I can replace that with "goto error" and give an error message on it like the other recently merged drivers do in this init situation.

i know there's inconsistency here with some drivers, but the current "best practices" is to not leak and return 0.

Quoted 5 lines
Quoted 1 line

also, you should return 0 here not -1

The recently merged drivers (armada100 - heavvy reviewed and you and many others, the xilinx_axi_emac(acked by you) and many more return -1 on malloc error.

i'm not perfect and sometimes i miss things :)

Quoted 11 lines
Quoted 6 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 733

Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	if (!get_prom(dev->enetaddr, nic.base))
+		return -1;
+
+	dp83902a_init(dev);

these should probably be in the eth->init step and not here

At first sight, I thought the same and did it the same but then you get

Net: NE2000
Warning: failed to set MAC address

OK, i looked closer at the code, and it does seem to only look up the MAC address, so this is correct to do in the ne2000_initialize() function. when i saw the diffstat, i thought the init was refactored to do more, not less.

Quoted 7 lines
Quoted 4 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 735

Quoted 1 line
drivers/net/ne2000_base.c +1 -0
+	eth_setenv_enetaddr("ethaddr", dev->enetaddr);

NAK: implement eth->write_hwaddr, and the driver should only use dev->enetaddr rather than touching the env

Wrong NAK: If ethaddr is not set in env, this "return -1" below triggers and no call to eth->write_hwaddr can be reached (below the return -1):

a bug in a diff layer doesn't mean you can add hacks to the driver. if the hardware supports changing the MAC at runtime by programming the registers, then implement write_hwaddr. if it doesn't, and you think the current eth behavior undesirable, then start a new thread.
-mike

#4 lore raw

PATCH 1/1 ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

Quoted 8 lines · On Monday 17 October 2011 18:26:38 Mike Frysinger wrote:
Quoted 7 lines · On Monday 17 October 2011 18:05:28 Bernhard Kaindl wrote:
Quoted 6 lines

drivers/net/ne2000_base.c int eth_send(volatile void *packet, int length) { · line 728

Quoted 4 lines
drivers/net/ne2000_base.c +4 -0
+	dev = calloc(sizeof(*dev), 1);
+	pbuf = malloc(NE2000_RX_BUFFER_SIZE);
+	if (dev == NULL || pbuf == NULL)
+		return -1;

if dev worked but pbuf failed, this leaks memory

Quoted 8 lines
Quoted 5 lines

If malloc fails here, either CONFIG_SYS_MALLOC_LEN is to small or malloc is broken. Three Ethernet drivers call hang() in this case, which is probably best in explaining to the developer who broke it.
I can replace that with "goto error" and give an error message on it like the other recently merged drivers do in this init situation.

i know there's inconsistency here with some drivers, but the current "best practices" is to not leak and return 0.

meh, for now, keep the -1. but don't leak. i'll review the drivers and update the documentation.
-mike

#5 lore raw

PATCH v2 1/1 ne2000: Convert to new net-multi model, fixes build of three boards

This fixes the build of the two sh boards shmin and r7780mp and qemu-mips which currently fail to build due to dropped pre-CONFIG_NET_MULTI code.

This v2 patch minimizes the number of lines in the diff for easy review and to eliminate any possible accidential changes resulting from moving lines of code in the file. This also makes the register function very easy.

Any cleanups and improvements are intentionally deferred to follow-up patches to keep this patch as simple and as easy to review as possible.

A new driver register function, ne2k_register() calls the existing one-time setup part of the old init function and calls eth_register().

Changes to shmin, r7780mp and qemu-mips:
- Call the new ne2k_register() from board_eth_init() of the boards.

- Tested using qemu-mips board,
- Tested the two renesas / sh boards r7780mp and shmin to compile again, and should work.

checkpatch-clean when "--ignore VOLATILE" is added to .checkpatch.conf, and no warnings introduced in none of the three boards using this driver.

---
 board/qemu-mips/qemu-mips.c     |    6 ++
 board/renesas/r7780mp/r7780mp.c |    3 +-
 board/shmin/shmin.c             |    6 ++
 drivers/net/ne2000_base.c       |   99 ++++++++++++++++++++++++++++-----------
 include/netdev.h                |    1 +
 5 files changed, 86 insertions(+), 29 deletions(-)
board/qemu-mips/qemu-mips.c +6 -0
index 7a69a00..2b3a1d6 100644
@@ -25,6 +25,7 @@
 #include <command.h>
 #include <asm/mipsregs.h>
 #include <asm/io.h>
+#include <netdev.h>
 
 phys_size_t initdram(int board_type)
 {
@@ -87,3 +88,8 @@ int misc_init_r(void)
 	set_io_port_base(0);
 	return 0;
 }
+
+int board_eth_init(bd_t *bis)
+{
+	return ne2k_register();
+}
board/renesas/r7780mp/r7780mp.c +2 -1
index 0b80099..82cef02 100644
@@ -81,5 +81,6 @@ void pci_init_board(void)
 
 int board_eth_init(bd_t *bis)
 {
-	return pci_eth_init(bis);
+	/* return >= 0 if a chip is found, the board's AX88796L is n2k-based */
+	return ne2k_register() + pci_eth_init(bis);
 }
board/shmin/shmin.c +6 -0
index 8742f10..7348f52 100644
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/processor.h>
+#include <netdev.h>
 
 int checkboard(void)
 {
@@ -55,6 +56,11 @@ int dram_init(void)
 	return 0;
 }
 
+int board_eth_init(bd_t *bis)
+{
+	return ne2k_register();
+}
+
 void led_set_state(unsigned short value)
 {
 
drivers/net/ne2000_base.c +71 -28

155 lines not on this page · raw message

include/netdev.h +1 -0
index 669f60b..38308e4 100644
@@ -79,6 +79,7 @@ int mpc8220_fec_initialize(bd_t *bis);
 int mpc82xx_scc_enet_initialize(bd_t *bis);
 int mvgbe_initialize(bd_t *bis);
 int natsemi_initialize(bd_t *bis);
+int ne2k_register(void);
 int npe_initialize(bd_t *bis);
 int ns8382x_initialize(bd_t *bis);
 int pcnet_initialize(bd_t *bis);
Signature · 1 line
1.7.3.4
#6 lore raw

PATCH v2 1/1 ne2000: Convert to new net-multi model, fixes build of three boards

Quoted 24 lines

This fixes the build of the two sh boards shmin and r7780mp and qemu-mips which currently fail to build due to dropped pre-CONFIG_NET_MULTI code.

This v2 patch minimizes the number of lines in the diff for easy review and to eliminate any possible accidential changes resulting from moving lines of code in the file. This also makes the register function very easy.

Any cleanups and improvements are intentionally deferred to follow-up patches to keep this patch as simple and as easy to review as possible.

A new driver register function, ne2k_register() calls the existing one-time setup part of the old init function and calls eth_register().

Changes to shmin, r7780mp and qemu-mips:
- Call the new ne2k_register() from board_eth_init() of the boards.

- Tested using qemu-mips board,
- Tested the two renesas / sh boards r7780mp and shmin to compile again, and should work.

checkpatch-clean when "--ignore VOLATILE" is added to .checkpatch.conf, and no warnings introduced in none of the three boards using this driver.

Quoted 9 lines
---
 board/qemu-mips/qemu-mips.c     |    6 ++
 board/renesas/r7780mp/r7780mp.c |    3 +-
 board/shmin/shmin.c             |    6 ++
 drivers/net/ne2000_base.c       |   99
++++++++++++++++++++++++++++----------- include/netdev.h                | 
  1 +
 5 files changed, 86 insertions(+), 29 deletions(-)

I think this patch is absolutelly essential to have in .12 release. I'll test it now and ev. rebase and resubmit. Bernhard, you're ok with me doing minor fixes?

M

#7 lore raw

PATCH v2 1/1 ne2000: Convert to new net-multi model, fixes build of three boards

In reply to Bernhard Kaindl

Dear Bernhard Kaindl,

Quoted 23 lines · In message <[email protected]> you…

This fixes the build of the two sh boards shmin and r7780mp and qemu-mips which currently fail to build due to dropped pre-CONFIG_NET_MULTI code.

This v2 patch minimizes the number of lines in the diff for easy review and to eliminate any possible accidential changes resulting from moving lines of code in the file. This also makes the register function very easy.

Any cleanups and improvements are intentionally deferred to follow-up patches to keep this patch as simple and as easy to review as possible.

A new driver register function, ne2k_register() calls the existing one-time setup part of the old init function and calls eth_register().

Changes to shmin, r7780mp and qemu-mips:
- Call the new ne2k_register() from board_eth_init() of the boards.

- Tested using qemu-mips board,
- Tested the two renesas / sh boards r7780mp and shmin to compile again, and should work.

checkpatch-clean when "--ignore VOLATILE" is added to .checkpatch.conf, and no warnings introduced in none of the three boards using this driver.

Quoted 8 lines
---
 board/qemu-mips/qemu-mips.c     |    6 ++
 board/renesas/r7780mp/r7780mp.c |    3 +-
 board/shmin/shmin.c             |    6 ++
 drivers/net/ne2000_base.c       |   99 ++++++++++++++++++++++++++++-----------
 include/netdev.h                |    1 +
 5 files changed, 86 insertions(+), 29 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
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 understand a program you must become  both  the  machine  and  the
program.
#8 lore raw

PATCH v2 1/1 ne2000: Convert to new net-multi model, fixes build of three boards

In reply to Bernhard Kaindl
Quoted 8 lines · On Thursday 20 October 2011 16:56:59 Bernhard Kaindl wrote:
drivers/net/ne2000_base.c +5 -0
 
+	/*
+	 * According to doc/README.enetaddr, drivers shall give priority
+	 * to the MAC address value in the environment, so we do not read
+	 * it from the prom or eeprom if it is specified in the environment.
+	 */

drivers/net/ne2000_base.c int eth_init(bd_t *bd) { · line 727

Quoted 10 lines
drivers/net/ne2000_base.c +10 -0
+	if (!eth_getenv_enetaddr("ethaddr", dev->enetaddr)) {
+		/* If the MAC address is not in the environment, get it: */
+		if (!get_prom(dev->enetaddr, nic.base)) /* get MAC from prom */
+			dp83902a_init(dev->enetaddr);   /* fallback: seeprom */
+		/* And write it into the environment otherwise eth_write_hwaddr
+		 * returns -1 due to eth_getenv_enetaddr_by_index() failing,
+		 * and this causes "Warning: failed to set MAC address", and
+		 * cmd_bdinfo has no ethaddr value which it can show: */
+		eth_setenv_enetaddr("ethaddr", dev->enetaddr);
+	}

this env parsing doesn't belong here. the net drivers only read dev-

Quoted 1 line

enetaddr. can you post a patch to drop this ?

-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111208/4cf587d4/attachment.pgp>