diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-09-30 10:48:40 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-09-30 10:48:40 +0200 |
commit | 20ec9ba02d908bb97b95838451b14f1a4589fa4c (patch) | |
tree | 2fab6cdcd630552c5830176ba193a5abd8680f2a /net | |
parent | ae3f56c84aee3cb9213abcc49b897651d4c534e7 (diff) | |
download | barebox-20ec9ba02d908bb97b95838451b14f1a4589fa4c.tar.gz barebox-20ec9ba02d908bb97b95838451b14f1a4589fa4c.tar.xz |
Ethernet: write MAC address to hardware when it's changed
Instead of writing the MAC address into the hardware on device open time
write it to the hardware when the user changes the parameter. This
way a user can change the MAC address in the hardware without actually
using the device. This helps Linux Network drivers which expect a valid
MAC address on startup.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/eth.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -49,10 +49,6 @@ int eth_open(void) if (!eth_current) return 0; - string_to_ethaddr(dev_get_param(eth_current->dev, "ethaddr"), mac); - - eth_current->set_ethaddr(eth_current, mac); - eth_current->open(eth_current); return 0; @@ -86,6 +82,7 @@ int eth_rx(void) static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const char *val) { + struct eth_device *edev = dev->type_data; char ethaddr[sizeof("xx:xx:xx:xx:xx:xx")]; if (string_to_ethaddr(val, ethaddr) < 0) @@ -94,6 +91,8 @@ static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const ch free(param->value); param->value = strdup(val); + edev->set_ethaddr(edev, ethaddr); + return 0; } @@ -137,15 +136,14 @@ int eth_register(struct eth_device *edev) dev_add_param(dev, &edev->param_netmask); dev_add_param(dev, &edev->param_serverip); + edev->init(edev); + if (edev->get_ethaddr(edev, ethaddr) == 0) { ethaddr_to_string(ethaddr, ethaddr_str); printf("got MAC address from EEPROM: %s\n",ethaddr_str); dev_set_param(dev, "ethaddr", ethaddr_str); -// memcpy(edev->enetaddr, ethaddr, 6); } - edev->init(edev); - eth_current = edev; return 0; |