[PATCH 3/3] net/eth: fix link handling
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Wed Sep 26 07:53:31 EDT 2012
The current code handle just the send where we are supposed to the same on rx
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
net/eth.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/net/eth.c b/net/eth.c
index d3bda81..402e479 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -124,7 +124,7 @@ int eth_complete(struct string_list *sl, char *instr)
}
#endif
-int eth_send(void *packet, int length)
+int eth_open(void)
{
int ret;
@@ -145,6 +145,17 @@ int eth_send(void *packet, int length)
if (!eth_current->active)
return -ENETDOWN;
+ return 0;
+}
+
+int eth_send(void *packet, int length)
+{
+ int ret;
+
+ ret = eth_open();
+ if (ret)
+ return ret;
+
led_trigger_network(LED_TRIGGER_NET_TX);
return eth_current->send(eth_current, packet, length);
@@ -154,15 +165,9 @@ int eth_rx(void)
{
int ret;
- if (!eth_current)
- return -ENODEV;
-
- if (!eth_current->active) {
- ret = eth_current->open(eth_current);
- if (ret)
- return ret;
- eth_current->active = 1;
- }
+ ret = eth_open();
+ if (ret)
+ return ret;
return eth_current->recv(eth_current);
}
--
1.7.10.4
More information about the barebox
mailing list