[U-Boot] [RFC PATCH v4 07/23] net: Change return codes from net/eth.c to use errorno constants

Joe Hershberger joe.hershberger at ni.com
Wed Feb 25 01:02:16 CET 2015


Many functions returned -1 previously. Change them to return appropriate error
codes.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
Reported-by: Simon Glass <sjg at chromium.org>

---

Changes in v4:
-New to v4

Changes in v3: None
Changes in v2: None

 net/eth.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 3df3c11..214375b 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -225,7 +225,7 @@ int eth_unregister(struct eth_device *dev)
 
 	/* No device */
 	if (!eth_devices)
-		return -1;
+		return -ENODEV;
 
 	for (cur = eth_devices; cur->next != eth_devices && cur->next != dev;
 	     cur = cur->next)
@@ -233,7 +233,7 @@ int eth_unregister(struct eth_device *dev)
 
 	/* Device not found */
 	if (cur->next != dev)
-		return -1;
+		return -ENODEV;
 
 	cur->next = dev->next;
 
@@ -366,7 +366,7 @@ int eth_init(bd_t *bis)
 
 	if (!eth_current) {
 		puts("No ethernet found.\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	/* Sync environment with network devices */
@@ -395,7 +395,7 @@ int eth_init(bd_t *bis)
 		eth_try_another(0);
 	} while (old_current != eth_current);
 
-	return -1;
+	return -ETIMEDOUT;
 }
 
 void eth_halt(void)
@@ -411,7 +411,7 @@ void eth_halt(void)
 int eth_send(void *packet, int length)
 {
 	if (!eth_current)
-		return -1;
+		return -ENODEV;
 
 	return eth_current->send(eth_current, packet, length);
 }
@@ -419,7 +419,7 @@ int eth_send(void *packet, int length)
 int eth_rx(void)
 {
 	if (!eth_current)
-		return -1;
+		return -ENODEV;
 
 	return eth_current->recv(eth_current);
 }
-- 
1.7.11.5



More information about the U-Boot mailing list