From 2230eea29b6e630d2ff27430f1968959b069db0b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 6 Apr 2009 18:54:56 +0200 Subject: [PATCH] net: add eth_unregister function Signed-off-by: Sascha Hauer --- include/net.h | 3 ++- net/eth.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/net.h b/include/net.h index d59ae5caa..63e25a012 100644 --- a/include/net.h +++ b/include/net.h @@ -78,7 +78,8 @@ struct eth_device { struct device_d *dev; }; -int eth_register(struct eth_device* dev);/* Register network device */ +int eth_register(struct eth_device* dev); /* Register network device */ +void eth_unregister(struct eth_device* dev); /* Unregister network device */ int eth_open(void); /* open the device */ int eth_send(void *packet, int length); /* Send a packet */ diff --git a/net/eth.c b/net/eth.c index e74ab3b5c..139893c58 100644 --- a/net/eth.c +++ b/net/eth.c @@ -148,3 +148,20 @@ int eth_register(struct eth_device *edev) return 0; } +void eth_unregister(struct eth_device *edev) +{ + if (edev->param_ip.value) + free(edev->param_ip.value); + if (edev->param_ethaddr.value) + free(edev->param_ethaddr.value); + if (edev->param_gateway.value) + free(edev->param_gateway.value); + if (edev->param_netmask.value) + free(edev->param_netmask.value); + if (edev->param_serverip.value) + free(edev->param_serverip.value); + + if (eth_current == edev) + eth_current = NULL; +} +