mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-30 11:01:33 +00:00
Add eth_get_dev_by_index
This allows code to iterate through the ethernet devices Signed-off-by: Andy Fleming <afleming@freescale.com>
This commit is contained in:
parent
b67305120a
commit
9e56986a2b
1 changed files with 22 additions and 0 deletions
22
net/eth.c
22
net/eth.c
|
@ -80,6 +80,28 @@ struct eth_device *eth_get_dev_by_name(char *devname)
|
||||||
return target_dev;
|
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)
|
int eth_get_dev_index (void)
|
||||||
{
|
{
|
||||||
struct eth_device *dev;
|
struct eth_device *dev;
|
||||||
|
|
Loading…
Add table
Reference in a new issue