summaryrefslogtreecommitdiff
path: root/net/eth.c
diff options
context:
space:
mode:
authorAndy Fleming <afleming@freescale.com>2009-02-11 15:07:24 -0600
committerAndy Fleming <afleming@freescale.com>2009-02-16 18:05:53 -0600
commit9e56986a2b74d197f51eca70fad7b836b1900c4d (patch)
tree1a90d6595113ef81e78374b8cd2f07d255e17ddf /net/eth.c
parentb67305120aaf268a6140125346678166d14f1f47 (diff)
downloadu-boot-imx-9e56986a2b74d197f51eca70fad7b836b1900c4d.zip
u-boot-imx-9e56986a2b74d197f51eca70fad7b836b1900c4d.tar.gz
u-boot-imx-9e56986a2b74d197f51eca70fad7b836b1900c4d.tar.bz2
Add eth_get_dev_by_index
This allows code to iterate through the ethernet devices Signed-off-by: Andy Fleming <afleming@freescale.com>
Diffstat (limited to 'net/eth.c')
-rw-r--r--net/eth.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/net/eth.c b/net/eth.c
index b7ef09f..ec2ef1a 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -80,6 +80,28 @@ struct eth_device *eth_get_dev_by_name(char *devname)
return target_dev;
}
+struct eth_device *eth_get_dev_by_index(int index)
+{
+ struct eth_device *dev, *target_dev;
+ int idx = 0;
+
+ if (!eth_devices)
+ return NULL;
+
+ dev = eth_devices;
+ target_dev = NULL;
+ do {
+ if (idx == index) {
+ target_dev = dev;
+ break;
+ }
+ dev = dev->next;
+ idx++;
+ } while (dev != eth_devices);
+
+ return target_dev;
+}
+
int eth_get_dev_index (void)
{
struct eth_device *dev;