* [U-Boot] [PATCH] Add eth_get_dev_by_index
@ 2009-02-11 0:55 Andy Fleming
2009-02-11 1:01 ` Mike Frysinger
2009-02-11 5:15 ` Ben Warren
0 siblings, 2 replies; 6+ messages in thread
From: Andy Fleming @ 2009-02-11 0:55 UTC (permalink / raw)
To: u-boot
This allows code to iterate through the ethernet devices
Also does some whitespace cleanup
Signed-off-by: Andy Fleming <afleming@freescale.com>
---
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(-)
diff --git a/include/net.h b/include/net.h
index bbe0d4b..fc14615 100644
--- a/include/net.h
+++ b/include/net.h
@@ -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);
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;
--
1.5.4.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] Add eth_get_dev_by_index
2009-02-11 0:55 [U-Boot] [PATCH] Add eth_get_dev_by_index Andy Fleming
@ 2009-02-11 1:01 ` Mike Frysinger
2009-02-11 1:43 ` Andy Fleming
2009-02-11 5:15 ` Ben Warren
1 sibling, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2009-02-11 1:01 UTC (permalink / raw)
To: u-boot
On Tuesday 10 February 2009 19:55:35 Andy Fleming wrote:
> diff --git a/include/net.h b/include/net.h
> index bbe0d4b..fc14615 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -116,18 +116,19 @@
looks like a lot of pointless whitespace changes when there should just be 1
new line: the prototype
-mike
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] Add eth_get_dev_by_index
2009-02-11 1:01 ` Mike Frysinger
@ 2009-02-11 1:43 ` Andy Fleming
2009-02-11 2:44 ` Mike Frysinger
2009-02-11 11:47 ` Wolfgang Denk
0 siblings, 2 replies; 6+ messages in thread
From: Andy Fleming @ 2009-02-11 1:43 UTC (permalink / raw)
To: u-boot
On Tue, Feb 10, 2009 at 7:01 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 10 February 2009 19:55:35 Andy Fleming wrote:
>> diff --git a/include/net.h b/include/net.h
>> index bbe0d4b..fc14615 100644
>> --- a/include/net.h
>> +++ b/include/net.h
>> @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] Add eth_get_dev_by_index
2009-02-11 1:43 ` Andy Fleming
@ 2009-02-11 2:44 ` Mike Frysinger
2009-02-11 11:47 ` Wolfgang Denk
1 sibling, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2009-02-11 2:44 UTC (permalink / raw)
To: u-boot
On Tuesday 10 February 2009 20:43:54 Andy Fleming wrote:
> On Tue, Feb 10, 2009 at 7:01 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On Tuesday 10 February 2009 19:55:35 Andy Fleming wrote:
> >> diff --git a/include/net.h b/include/net.h
> >> index bbe0d4b..fc14615 100644
> >> --- a/include/net.h
> >> +++ b/include/net.h
> >> @@ -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.
throwing it in an unrelated patch looks wrong
-mike
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] Add eth_get_dev_by_index
2009-02-11 0:55 [U-Boot] [PATCH] Add eth_get_dev_by_index Andy Fleming
2009-02-11 1:01 ` Mike Frysinger
@ 2009-02-11 5:15 ` Ben Warren
1 sibling, 0 replies; 6+ messages in thread
From: Ben Warren @ 2009-02-11 5:15 UTC (permalink / raw)
To: u-boot
Andy Fleming wrote:
> This allows code to iterate through the ethernet devices
>
> Also does some whitespace cleanup
>
> Signed-off-by: Andy Fleming <afleming@freescale.com>
>
Acked-by: Ben Warren <biggerbadderben@gmail.com>
> ---
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] Add eth_get_dev_by_index
2009-02-11 1:43 ` Andy Fleming
2009-02-11 2:44 ` Mike Frysinger
@ 2009-02-11 11:47 ` Wolfgang Denk
1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2009-02-11 11:47 UTC (permalink / raw)
To: u-boot
Dear Andy Fleming,
In message <2acbd3e40902101743w5d9dc788lb05170769790103f@mail.gmail.com> you wrote:
>
> > 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:
...
> 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
--
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-11 11:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 0:55 [U-Boot] [PATCH] Add eth_get_dev_by_index Andy Fleming
2009-02-11 1:01 ` Mike Frysinger
2009-02-11 1:43 ` Andy Fleming
2009-02-11 2:44 ` Mike Frysinger
2009-02-11 11:47 ` Wolfgang Denk
2009-02-11 5:15 ` Ben Warren
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.