diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-06-11 15:32:06 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-07-21 16:41:46 +0200 |
commit | 2f8df2a003a22e8b7397e51ac5f1796db920d579 (patch) | |
tree | f92f130a7a4522e6391174a02fdb3d82ba44e080 /net | |
parent | 56139274fda2ce914860a978d32d79bd43099ae1 (diff) | |
download | barebox-2f8df2a003a22e8b7397e51ac5f1796db920d579.tar.gz barebox-2f8df2a003a22e8b7397e51ac5f1796db920d579.tar.xz |
add a device_d to ethernet devices
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/eth.c | 11 | ||||
-rw-r--r-- | net/net.c | 18 |
2 files changed, 17 insertions, 12 deletions
@@ -44,12 +44,14 @@ struct eth_device * eth_get_current(void) return eth_current; } -struct eth_device *eth_get_byname(char *name) +struct eth_device *eth_get_byname(char *ethname) { struct eth_device *edev; + char name[MAX_DRIVER_NAME]; list_for_each_entry(edev, &netdev_list, list) { - if (!strcmp(edev->dev->id, name)) + sprintf(name, "%s%d", edev->dev.name, edev->dev.id); + if (!strcmp(ethname, name)) return edev; } return NULL; @@ -120,7 +122,7 @@ static int eth_set_ipaddr(struct device_d *dev, struct param_d *param, const cha int eth_register(struct eth_device *edev) { - struct device_d *dev = edev->dev; + struct device_d *dev = &edev->dev; unsigned char ethaddr_str[20]; unsigned char ethaddr[6]; @@ -129,6 +131,9 @@ int eth_register(struct eth_device *edev) return -1; } + strcpy(edev->dev.name, "eth"); + register_device(&edev->dev); + dev->type_data = edev; edev->param_ip.name = "ipaddr"; edev->param_ip.set = ð_set_ipaddr; @@ -258,7 +258,7 @@ NetLoop(proto_t protocol) return -1; } - ip = dev_get_param_ip(eth_current->dev, "ipaddr"); + ip = dev_get_param_ip(ð_current->dev, "ipaddr"); NetCopyIP(&NetOurIP, &ip); /* XXX problem with bss workaround */ @@ -291,16 +291,16 @@ NetLoop(proto_t protocol) return -1; restart: - string_to_ethaddr(dev_get_param(eth_get_current()->dev, "ethaddr"), + string_to_ethaddr(dev_get_param(ð_get_current()->dev, "ethaddr"), NetOurEther); NetState = NETLOOP_CONTINUE; - NetOurGatewayIP = dev_get_param_ip(eth_current->dev, "gateway"); - NetOurSubnetMask = dev_get_param_ip(eth_current->dev, "netmask"); + NetOurGatewayIP = dev_get_param_ip(ð_current->dev, "gateway"); + NetOurSubnetMask = dev_get_param_ip(ð_current->dev, "netmask"); NetOurVLAN = getenv_VLAN("vlan"); NetOurNativeVLAN = getenv_VLAN("nvlan"); - NetServerIP = dev_get_param_ip(eth_current->dev, "serverip"); + NetServerIP = dev_get_param_ip(ð_current->dev, "serverip"); /* * Start the ball rolling with the given start function. From @@ -894,7 +894,7 @@ NetReceive(uchar * inpkt, int len) static int net_check_prereq (proto_t protocol) { - char *ethid = eth_get_current()->dev->id; + struct eth_device *edev = eth_get_current(); switch (protocol) { /* Fall through */ @@ -920,13 +920,13 @@ static int net_check_prereq (proto_t protocol) case NETCONS: case TFTP: if (NetServerIP == 0) { - printf("*** ERROR: `%s.serverip' not set\n", ethid); + printf("*** ERROR: `%s.serverip' not set\n", dev_id(&edev->dev)); return (1); } common: if (NetOurIP == 0) { - printf("*** ERROR: `%s.ipaddr' not set\n", ethid); + printf("*** ERROR: `%s.ipaddr' not set\n", dev_id(&edev->dev)); return (1); } /* Fall through */ @@ -935,7 +935,7 @@ static int net_check_prereq (proto_t protocol) case RARP: case BOOTP: if (memcmp (NetOurEther, "\0\0\0\0\0\0", 6) == 0) { - printf("*** ERROR: `%s.ethaddr' not set\n", ethid); + printf("*** ERROR: `%s.ethaddr' not set\n", dev_id(&edev->dev)); return (1); } /* Fall through */ |