summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-06-11 15:32:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-07-21 16:41:46 +0200
commit2f8df2a003a22e8b7397e51ac5f1796db920d579 (patch)
treef92f130a7a4522e6391174a02fdb3d82ba44e080 /net
parent56139274fda2ce914860a978d32d79bd43099ae1 (diff)
downloadbarebox-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.c11
-rw-r--r--net/net.c18
2 files changed, 17 insertions, 12 deletions
diff --git a/net/eth.c b/net/eth.c
index b8a61a2a46..7570198a17 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -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 = &eth_set_ipaddr;
diff --git a/net/net.c b/net/net.c
index 437a400a06..49250141ec 100644
--- a/net/net.c
+++ b/net/net.c
@@ -258,7 +258,7 @@ NetLoop(proto_t protocol)
return -1;
}
- ip = dev_get_param_ip(eth_current->dev, "ipaddr");
+ ip = dev_get_param_ip(&eth_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(&eth_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(&eth_current->dev, "gateway");
+ NetOurSubnetMask = dev_get_param_ip(&eth_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(&eth_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 */