[U-Boot] [PATCH] net: add altera triple speeds ethernet mac driver
Mike Frysinger
vapier at gentoo.org
Wed Mar 24 08:51:50 CET 2010
On Wednesday 24 March 2010 02:32:46 Thomas Chou wrote:
> +int altera_tse_init(bd_t *bis, int num_tses)
so "num_tses" is the # of devices to allocate ...
> + return 1;
... but you always return 1. this should probably be num_tses.
> + for (num = 0; num < num_tses; num++) {
> + dev = (struct eth_device *)malloc(sizeof *dev);
> +
> + if (NULL == dev)
> + return 0;
> +
> + memset(dev, 0, sizeof *dev);
> +
> + priv = (struct altera_tse_priv *)malloc(sizeof(*priv));
malloc returns (void *), so i dont think you need the casts
> + if (NULL == priv)
> + return 0;
this leaks the memory given to dev when there's an error
> + if (NULL == rx_desc || NULL == tx_desc)
> + return 0;
an error here should probably free the current dev/priv structures
> + /* Tell u-boot to get the addr from the env */
> + for (i = 0; i < 6; i++)
> + dev->enetaddr[i] = 0;
you called memset() on *dev already, so this explicit enetaddr init is not
needed
> --- /dev/null
> +++ b/include/altera_tse.h
this should probably live alongside the driver rather than in include/
-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/20100324/650128c6/attachment.pgp
More information about the U-Boot
mailing list