summaryrefslogtreecommitdiffstats
path: root/net/eth.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:25 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:25 +0200
commita0b0cfc5ed9759a50aefc264c7490b19d617d12b (patch)
treead31938638788dd77bc56bad43987f5ea3203693 /net/eth.c
parent55ebf67d3ec2b0727f86a54157a2740e9e8472c3 (diff)
downloadbarebox-a0b0cfc5ed9759a50aefc264c7490b19d617d12b.tar.gz
barebox-a0b0cfc5ed9759a50aefc264c7490b19d617d12b.tar.xz
svn_rev_121
implement device parameters
Diffstat (limited to 'net/eth.c')
-rw-r--r--net/eth.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/net/eth.c b/net/eth.c
index ba3b9320eb..bcfbe6fa25 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -27,6 +27,43 @@
#include <init.h>
#include <net.h>
#include <miiphy.h>
+#include <malloc.h>
+
+typedef enum eth_cookies {
+ PARAM_IP,
+ PARAM_MAC,
+ PARAM_GW,
+ PARAM_NM,
+} eth_cookies_t;
+
+static char *eth_get(struct device_d* dev, ulong cookie)
+{
+ struct eth_device *ndev = dev->driver->type_data;
+
+ if (cookie >= 4)
+ return 0;
+
+ return ndev->param[cookie];
+}
+
+static int eth_set(struct device_d* dev, ulong cookie, char *newval)
+{
+ struct eth_device *ndev = dev->driver->type_data;
+ char **val = &ndev->param[cookie];
+
+ if (*val)
+ free(*val);
+
+ *val = newval;
+ return 0;
+}
+
+static struct param_d eth_params[] = {
+ { .name = "ip", .cookie = PARAM_IP, .set = eth_set, .get = eth_get},
+ { .name = "mac", .cookie = PARAM_MAC, .set = eth_set, .get = eth_get},
+ { .name = "gateway", .cookie = PARAM_GW, .set = eth_set, .get = eth_get},
+ { .name = "netmask", .cookie = PARAM_NM, .set = eth_set, .get = eth_get},
+};
static struct eth_device *eth_current;
@@ -85,12 +122,14 @@ static int eth_handle(struct device_d *dev)
char *e = NULL;
int i;
- printf("%s: %s\n",__FUNCTION__, dev->id);
if (!ndev->get_mac_address) {
printf("no get_mac_address found for current eth device\n");
return -1;
}
+ for (i = 0; i < 4; i++)
+ dev_add_parameter(dev, &eth_params[i]);
+
ethaddr = ndev->enetaddr;
/* Try to get a MAC address from the eeprom set 'ethaddr' to it.