diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-06 18:26:10 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-11 11:48:34 +0200 |
commit | 6d0161d02a3a829a12b85bdd3a71cddb714d66f5 (patch) | |
tree | 0e19b1192dd2d8029b4dc2f733d52f6a674d81af /net/eth.c | |
parent | 7d29b3cd83be22c8c714e5e1b331cf832cf03dd2 (diff) | |
download | barebox-6d0161d02a3a829a12b85bdd3a71cddb714d66f5.tar.gz barebox-6d0161d02a3a829a12b85bdd3a71cddb714d66f5.tar.xz |
net: store ethernet device parameters in device
Rather than storing the parameters globally and trying to keep them
in sync with the device parameters, store the parameters in the ethernet
device directly. Also, update to dev_add_param_ip().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net/eth.c')
-rw-r--r-- | net/eth.c | 40 |
1 files changed, 7 insertions, 33 deletions
@@ -86,7 +86,6 @@ void eth_set_current(struct eth_device *eth) } eth_current = eth; - net_update_env(); } struct eth_device * eth_get_current(void) @@ -210,39 +209,16 @@ 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_to_edev(dev); - u8 ethaddr[6]; - - if (!val) - return dev_param_set_generic(dev, param, NULL); - - if (string_to_ethaddr(val, ethaddr) < 0) - return -EINVAL; - - dev_param_set_generic(dev, param, val); - - edev->set_ethaddr(edev, ethaddr); - - if (edev == eth_current) - net_update_env(); - - return 0; -} - -static int eth_set_ipaddr(struct device_d *dev, struct param_d *param, const char *val) -{ - struct eth_device *edev = dev_to_edev(dev); - IPaddr_t ip; if (!val) return dev_param_set_generic(dev, param, NULL); - if (string_to_ip(val, &ip)) + if (string_to_ethaddr(val, edev->ethaddr) < 0) return -EINVAL; dev_param_set_generic(dev, param, val); - if (edev == eth_current) - net_update_env(); + edev->set_ethaddr(edev, edev->ethaddr); return 0; } @@ -267,11 +243,11 @@ int eth_register(struct eth_device *edev) register_device(&edev->dev); - dev_add_param(dev, "ipaddr", eth_set_ipaddr, NULL, 0); + dev_add_param_ip(dev, "ipaddr", NULL, NULL, &edev->ipaddr, edev); + dev_add_param_ip(dev, "serverip", NULL, NULL, &edev->serverip, edev); + dev_add_param_ip(dev, "gateway", NULL, NULL, &edev->gateway, edev); + dev_add_param_ip(dev, "netmask", NULL, NULL, &edev->netmask, edev); dev_add_param(dev, "ethaddr", eth_set_ethaddr, NULL, 0); - dev_add_param(dev, "gateway", eth_set_ipaddr, NULL, 0); - dev_add_param(dev, "netmask", eth_set_ipaddr, NULL, 0); - dev_add_param(dev, "serverip", eth_set_ipaddr, NULL, 0); if (edev->init) edev->init(edev); @@ -296,10 +272,8 @@ int eth_register(struct eth_device *edev) } } - if (!eth_current) { + if (!eth_current) eth_current = edev; - net_update_env(); - } return 0; } |