[U-Boot] [PATCH] net: add opencore 10/100 ethernet mac driver
Mike Frysinger
vapier at gentoo.org
Wed Mar 24 08:54:46 CET 2010
On Wednesday 24 March 2010 02:24:41 Thomas Chou wrote:
> +static int ethoc_set_mac_address(struct eth_device *dev, void *addr)
> +{
> + struct ethoc *priv = (void *)dev->priv;
> + u8 *mac = (u8 *) addr;
> +
> + ethoc_write(priv, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) |
> + (mac[4] << 8) | (mac[5] << 0));
> + ethoc_write(priv, MAC_ADDR1, (mac[0] << 8) | (mac[1] << 0));
> +
> + return 0;
> +}
> +
> +static int ethoc_init(struct eth_device *dev, bd_t * bd)
> +{
> + eth_getenv_enetaddr("ethaddr", dev->enetaddr);
> + ethoc_set_mac_address(dev, dev->enetaddr);
yikes ! drivers shouldnt be poking the env -- the common net layer handles
syncing the env and the eth_device structure for you. so the code should
simply be:
ethoc_set_mac_address(dev);
and that function works off of dev->enetaddr. or pass it dev->enetaddr and
have it work off the specified buffer. your choice.
-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/83fb1a3e/attachment.pgp
More information about the U-Boot
mailing list