Add eth_get_dev_by_index
PATCH 1/1 Add eth_get_dev_by_index
This allows code to iterate through the ethernet devices
Also does some whitespace cleanup
---
Sorry this is so late. This has been sitting in my tree, and is required for a patch for 85xx. It's included in my upcoming pull request, as long as Ben approves...
include/net.h | 19 ++++++++++--------- net/eth.c | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-)
include/net.h +10 -9
@@ -116,18 +116,19 @@ extern void eth_try_another(int first_restart); /* Change the device */extern void eth_set_current (void );/* set nterface to ethcur var. */ #endif extern struct eth_device *eth_get_dev (void );/* get the current device MAC */ -extern struct eth_device *eth_get_dev_by_name (char *devname);/* get device */ -extern int eth_get_dev_index (void );/* get the device index */ -extern void eth_set_enetaddr (int num,char * a);/* Set new MAC address */ +extern struct eth_device *eth_get_dev_by_name (char *devname);/* get device */ +extern struct eth_device *eth_get_dev_by_index (int index);/* get dev @ index */ +extern int eth_get_dev_index (void );/* get the device index */ +extern void eth_set_enetaddr (int num,char * a);/* Set new MAC address */ -extern int eth_init (bd_t *bis);/* Initialize the device */ -extern int eth_send (volatile void *packet,int length);/* Send a packet */ +extern int eth_init (bd_t *bis);/* Initialize the device */ +extern int eth_send (volatile void *packet,int length);/* Send a packet */ #ifdef CONFIG_API -extern int eth_receive (volatile void *packet,int length);/* Receive a packet */ +extern int eth_receive (volatile void *packet,int length);/* Receive a packet*/ #endif -extern int eth_rx (void );/* Check for received packets */ -extern void eth_halt (void );/* stop SCC */ -extern char *eth_get_name (void );/* get name of current device */ +extern int eth_rx (void );/* Check for received packets */ +extern void eth_halt (void );/* stop SCC */ +extern char *eth_get_name (void );/* get name of current device */ #ifdef CONFIG_MCAST_TFTP int eth_mcast_join (IPaddr_t mcast_addr,u8 join);
net/eth.c +22 -0
@@ -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;
Signature · 1 line
1.5.4.GIT
PATCH 1/1 Add eth_get_dev_by_index
include/net.h
Quoted 5 lines · On Tuesday 10 February 2009 19:55:35 Andy Fleming wrote:
include/net.h +0
-0@@ -116,18 +116,19 @@
looks like a lot of pointless whitespace changes when there should just be 1 new line: the prototype
-mike
PATCH 1/1 Add eth_get_dev_by_index
Quoted 9 lines · Mike Frysinger
include/net.h
Quoted 5 lines · On Tuesday 10 February 2009 19:55:35 Andy Fleming wrote:
include/net.h +0
-0@@ -116,18 +116,19 @@looks like a lot of pointless whitespace changes when there should just be 1 new line: the prototype
They're not pointless, they fix it so that the lines are <= 80 characters wide. The comments had extra spaces which made every line look like:
foo blah /* this is a comment
*/
foo2 blah3 /* another one
*/
If people think the whitespace changes are too much, I'll move them into a separate patch.
Andy
PATCH 1/1 Add eth_get_dev_by_index
Quoted 15 lines · On Tuesday 10 February 2009 20:43:54 Andy Fleming wrote:
Quoted 9 lines · Mike Frysinger
include/net.h
Quoted 5 lines · On Tuesday 10 February 2009 19:55:35 Andy Fleming wrote:
include/net.h +0
-0@@ -116,18 +116,19 @@looks like a lot of pointless whitespace changes when there should just be 1 new line: the prototype
They're not pointless, they fix it so that the lines are <= 80 characters wide. The comments had extra spaces which made every line look like:
Quoted 7 lines
foo blah /* this is a comment
*/
foo2 blah3 /* another one
*/If people think the whitespace changes are too much, I'll move them into a separate patch.
throwing it in an unrelated patch looks wrong
-mike
PATCH 1/1 Add eth_get_dev_by_index
In reply to Andy FlemingDear Andy Fleming,
Quoted 7 lines · In message <[email protected]> you…
Quoted 3 lines
looks like a lot of pointless whitespace changes when there should just be 1 new line: the prototype
They're not pointless, they fix it so that the lines are <= 80 characters wide. The comments had extra spaces which made every line look like:
...
Quoted 2 lines
If people think the whitespace changes are too much, I'll move them into a separate patch.
Yes, please split this into two patches. Thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Artificial Intelligence is no match for natural stupidity.
PATCH 1/1 Add eth_get_dev_by_index
In reply to Andy FlemingQuoted 6 lines · Andy Fleming
This allows code to iterate through the ethernet devices
Also does some whitespace cleanup
Signed-off-by Andy Fleming <[email protected]>
Quoted 5 lines
---
Sorry this is so late. This has been sitting in my tree, and is required for a patch for 85xx. It's included in my upcoming pull request, as long as Ben approves...
Not supposed to mix functional fixes and coding style cleanup, but I don't care so much.
thanks,
Ben