From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Chou Date: Wed, 24 Mar 2010 21:38:33 +0800 Subject: [U-Boot] [PATCH] net: add opencore 10/100 ethernet mac driver In-Reply-To: <201003240354.46999.vapier@gentoo.org> References: <1269411881-8850-1-git-send-email-thomas@wytron.com.tw> <201003240354.46999.vapier@gentoo.org> Message-ID: <4BAA15D9.3060502@wytron.com.tw> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 03/24/2010 03:54 PM, Mike Frysinger wrote: > 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 > Hi Mike, Thank you. Please review the update. Best regards, Thomas