From: Andy Fleming Date: Wed, 11 Feb 2009 21:07:24 +0000 (-0600) Subject: Add eth_get_dev_by_index X-Git-Tag: v2009.03-rc1~72 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e56986a2b74d197f51eca70fad7b836b1900c4d;p=u-boot Add eth_get_dev_by_index This allows code to iterate through the ethernet devices Signed-off-by: Andy Fleming --- diff --git a/net/eth.c b/net/eth.c index b7ef09f447..ec2ef1a365 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;