[U-Boot] [PATCH] ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

Mike Frysinger vapier at gentoo.org
Sun Oct 16 21:39:30 CEST 2011


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 :/

> - 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

> --- a/board/qemu-mips/qemu-mips.c
> +++ b/board/qemu-mips/qemu-mips.c
>
> +int board_eth_init(bd_t *bis)
> +{
> +	return ne2000_initialize();
> +}
> --- a/board/shmin/shmin.c
> +++ b/board/shmin/shmin.c
>
> +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 ?

> --- a/drivers/net/ne2000_base.c
> +++ b/drivers/net/ne2000_base.c
>
> +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

> +	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

> +	if (!get_prom(dev->enetaddr, nic.base))
> +		return -1;
> +
> +	dp83902a_init(dev);

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

> +	eth_setenv_enetaddr("ethaddr", dev->enetaddr);

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

> +	/* 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

> --- a/include/netdev.h
> +++ b/include/netdev.h
>
> +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 


More information about the U-Boot mailing list