All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces
@ 2016-01-06 21:01 Lev Iserovich
  2016-01-07  2:42 ` Bin Meng
  2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
  0 siblings, 2 replies; 12+ messages in thread
From: Lev Iserovich @ 2016-01-06 21:01 UTC (permalink / raw)
  To: u-boot

For multiple ethernet interfaces the FDT offset of '/aliases' will change as we
are adding MAC addresses to the FDT.
Therefore only the first interface ('ethernet0') will get properly updated in
the FDT, with the rest getting FDT errors when we try to set their MAC address.

Switch to using fdt_get_alias() which is the proper way to get the FDT path.

Signed-off-by: Lev Iserovich <iserovil@deshawresearch.com>
---

 common/fdt_support.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 66464db..20e0e1c 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -481,16 +481,12 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
 
 void fdt_fixup_ethernet(void *fdt)
 {
-	int node, i, j;
+	int i, j;
 	char enet[16], *tmp, *end;
 	char mac[16];
 	const char *path;
 	unsigned char mac_addr[6];
 
-	node = fdt_path_offset(fdt, "/aliases");
-	if (node < 0)
-		return;
-
 	if (!getenv("ethaddr")) {
 		if (getenv("usbethaddr")) {
 			strcpy(mac, "usbethaddr");
@@ -505,7 +501,7 @@ void fdt_fixup_ethernet(void *fdt)
 	i = 0;
 	while ((tmp = getenv(mac)) != NULL) {
 		sprintf(enet, "ethernet%d", i);
-		path = fdt_getprop(fdt, node, enet, NULL);
+		path = fdt_get_alias(fdt, enet);
 		if (!path) {
 			debug("No alias for %s\n", enet);
 			sprintf(mac, "eth%daddr", ++i);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces
  2016-01-06 21:01 [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces Lev Iserovich
@ 2016-01-07  2:42 ` Bin Meng
  2016-01-07 20:21   ` Lev Iserovich
  2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
  1 sibling, 1 reply; 12+ messages in thread
From: Bin Meng @ 2016-01-07  2:42 UTC (permalink / raw)
  To: u-boot

Hi Lev,

On Thu, Jan 7, 2016 at 5:01 AM, Lev Iserovich
<iserovil@deshawresearch.com> wrote:
> For multiple ethernet interfaces the FDT offset of '/aliases' will change as we
> are adding MAC addresses to the FDT.

Could you please elaborate more under what situation the offset of
'/aliases' will change?

> Therefore only the first interface ('ethernet0') will get properly updated in
> the FDT, with the rest getting FDT errors when we try to set their MAC address.
>
> Switch to using fdt_get_alias() which is the proper way to get the FDT path.
>
> Signed-off-by: Lev Iserovich <iserovil@deshawresearch.com>
> ---
>
>  common/fdt_support.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 66464db..20e0e1c 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -481,16 +481,12 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
>
>  void fdt_fixup_ethernet(void *fdt)
>  {
> -       int node, i, j;
> +       int i, j;
>         char enet[16], *tmp, *end;
>         char mac[16];
>         const char *path;
>         unsigned char mac_addr[6];
>
> -       node = fdt_path_offset(fdt, "/aliases");
> -       if (node < 0)
> -               return;
> -
>         if (!getenv("ethaddr")) {
>                 if (getenv("usbethaddr")) {
>                         strcpy(mac, "usbethaddr");
> @@ -505,7 +501,7 @@ void fdt_fixup_ethernet(void *fdt)
>         i = 0;
>         while ((tmp = getenv(mac)) != NULL) {
>                 sprintf(enet, "ethernet%d", i);
> -               path = fdt_getprop(fdt, node, enet, NULL);
> +               path = fdt_get_alias(fdt, enet);

Can you please rebase your patch on top of the following two:

http://patchwork.ozlabs.org/patch/539373/
http://patchwork.ozlabs.org/patch/539374/

>                 if (!path) {
>                         debug("No alias for %s\n", enet);
>                         sprintf(mac, "eth%daddr", ++i);
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces
  2016-01-07  2:42 ` Bin Meng
@ 2016-01-07 20:21   ` Lev Iserovich
  0 siblings, 0 replies; 12+ messages in thread
From: Lev Iserovich @ 2016-01-07 20:21 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 01/06/2016 09:42 PM, Bin Meng wrote:
> Could you please elaborate more under what situation the offset of 
> '/aliases' will change? 
I believe the offset of '/aliases' will change because we're editing the 
device tree in place (adding the MAC address to it where it wasn't before),
and 'aliases' is at the very end of the device tree.
I've seen this happen on my board (Freescale LS1043A-RDB).
I added some debugging printf's to my code, and saw that all ethernet 
interfaces after ethernet0 get a 'FDT_ERR_BADOFFSET' from the 
fdt_getprop() call , and Linux comes up with only 1 interface.
After this fix all the interfaces come up properly in Linux with the 
right MAC addresses.
> Can you please rebase your patch on top of the following two:
>
> http://patchwork.ozlabs.org/patch/539373/
> http://patchwork.ozlabs.org/patch/539374/
The second patch seems like a rewrite of the scan through interfaces 
loop, so it's not a simple rebase.
I will attempt to do this, and send another patch soon.

Thanks,

Lev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-01-06 21:01 [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces Lev Iserovich
  2016-01-07  2:42 ` Bin Meng
@ 2016-01-07 23:04 ` Lev Iserovich
  2016-04-26 19:27   ` Joe Hershberger
                     ` (2 more replies)
  1 sibling, 3 replies; 12+ messages in thread
From: Lev Iserovich @ 2016-01-07 23:04 UTC (permalink / raw)
  To: u-boot

For multiple ethernet interfaces the FDT offset of '/aliases' will change as we
are adding MAC addresses to the FDT.
Therefore only the first interface ('ethernet0') will get properly updated in
the FDT, with the rest getting FDT errors when we try to set their MAC address.

Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
---

Changes in v2:
    - Rebase on u-boot-net patches:
      http://patchwork.ozlabs.org/patch/539373/
      http://patchwork.ozlabs.org/patch/539374/
    - Recompute offset based on property index

---

  common/fdt_support.c | 21 ++++++++++++++-------
  1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 48faba9..713d2a4 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -481,23 +481,30 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)

  void fdt_fixup_ethernet(void *fdt)
  {
-       int node, i, j;
+       int i, j, prop;
         char *tmp, *end;
         char mac[16];
         const char *path;
         unsigned char mac_addr[6];
         int offset;

-       node = fdt_path_offset(fdt, "/aliases");
-       if (node < 0)
+       if (fdt_path_offset(fdt, "/aliases") < 0)
                 return;
-
-       for (offset = fdt_first_property_offset(fdt, node);
-            offset > 0;
-            offset = fdt_next_property_offset(fdt, offset)) {
+
+       // Cycle through all aliases
+       for (prop = 0; ; prop++) {
                 const char *name;
                 int len = strlen("ethernet");

+               // FDT might have been edited, recompute the offset
+               offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt, "/aliases"));
+               // Select property number 'prop'
+               for (i = 0; i < prop; i++) {
+                       offset = fdt_next_property_offset(fdt, offset);
+               }
+               if (offset < 0)
+                       break;
+
                 path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
                 if (!strncmp(name, "ethernet", len)) {
                         i = trailing_strtol(name);

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
@ 2016-04-26 19:27   ` Joe Hershberger
  2016-04-27  0:06   ` Bin Meng
  2016-05-03 20:16   ` [U-Boot] " Joe Hershberger
  2 siblings, 0 replies; 12+ messages in thread
From: Joe Hershberger @ 2016-04-26 19:27 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 7, 2016 at 5:04 PM, Lev Iserovich
<Lev.Iserovich@deshawresearch.com> wrote:
> For multiple ethernet interfaces the FDT offset of '/aliases' will change as
> we
> are adding MAC addresses to the FDT.
> Therefore only the first interface ('ethernet0') will get properly updated
> in
> the FDT, with the rest getting FDT errors when we try to set their MAC
> address.
>
> Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
  2016-04-26 19:27   ` Joe Hershberger
@ 2016-04-27  0:06   ` Bin Meng
  2016-04-27  1:57     ` Bin Meng
  2016-05-02 16:01     ` Lev Iserovich
  2016-05-03 20:16   ` [U-Boot] " Joe Hershberger
  2 siblings, 2 replies; 12+ messages in thread
From: Bin Meng @ 2016-04-27  0:06 UTC (permalink / raw)
  To: u-boot

Hi Lev,

On Fri, Jan 8, 2016 at 7:04 AM, Lev Iserovich
<Lev.Iserovich@deshawresearch.com> wrote:
> For multiple ethernet interfaces the FDT offset of '/aliases' will change as
> we
> are adding MAC addresses to the FDT.
> Therefore only the first interface ('ethernet0') will get properly updated
> in
> the FDT, with the rest getting FDT errors when we try to set their MAC
> address.
>
> Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
> ---
>
> Changes in v2:
>    - Rebase on u-boot-net patches:
>      http://patchwork.ozlabs.org/patch/539373/
>      http://patchwork.ozlabs.org/patch/539374/
>    - Recompute offset based on property index
>
> ---
>
>  common/fdt_support.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 48faba9..713d2a4 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -481,23 +481,30 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
>
>  void fdt_fixup_ethernet(void *fdt)
>  {
> -       int node, i, j;
> +       int i, j, prop;
>         char *tmp, *end;
>         char mac[16];
>         const char *path;
>         unsigned char mac_addr[6];
>         int offset;
>
> -       node = fdt_path_offset(fdt, "/aliases");
> -       if (node < 0)
> +       if (fdt_path_offset(fdt, "/aliases") < 0)
>                 return;
> -
> -       for (offset = fdt_first_property_offset(fdt, node);
> -            offset > 0;
> -            offset = fdt_next_property_offset(fdt, offset)) {
> +
> +       // Cycle through all aliases

Please do not use C++ comment style.

> +       for (prop = 0; ; prop++) {
>                 const char *name;
>                 int len = strlen("ethernet");
>
> +               // FDT might have been edited, recompute the offset

ditto.

> +               offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt,
> "/aliases"));
> +               // Select property number 'prop'

ditto.

> +               for (i = 0; i < prop; i++) {
> +                       offset = fdt_next_property_offset(fdt, offset);
> +               }
> +               if (offset < 0)
> +                       break;
> +
>                 path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
>                 if (!strncmp(name, "ethernet", len)) {
>                         i = trailing_strtol(name);
>

Regards,
Bin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-04-27  0:06   ` Bin Meng
@ 2016-04-27  1:57     ` Bin Meng
  2016-05-02 17:12       ` Joe Hershberger
  2016-05-02 16:01     ` Lev Iserovich
  1 sibling, 1 reply; 12+ messages in thread
From: Bin Meng @ 2016-04-27  1:57 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 27, 2016 at 8:06 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Lev,
>
> On Fri, Jan 8, 2016 at 7:04 AM, Lev Iserovich
> <Lev.Iserovich@deshawresearch.com> wrote:
>> For multiple ethernet interfaces the FDT offset of '/aliases' will change as
>> we
>> are adding MAC addresses to the FDT.
>> Therefore only the first interface ('ethernet0') will get properly updated
>> in
>> the FDT, with the rest getting FDT errors when we try to set their MAC
>> address.
>>
>> Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
>> ---
>>
>> Changes in v2:
>>    - Rebase on u-boot-net patches:
>>      http://patchwork.ozlabs.org/patch/539373/
>>      http://patchwork.ozlabs.org/patch/539374/
>>    - Recompute offset based on property index
>>
>> ---
>>
>>  common/fdt_support.c | 21 ++++++++++++++-------
>>  1 file changed, 14 insertions(+), 7 deletions(-)
>>
>> diff --git a/common/fdt_support.c b/common/fdt_support.c
>> index 48faba9..713d2a4 100644
>> --- a/common/fdt_support.c
>> +++ b/common/fdt_support.c
>> @@ -481,23 +481,30 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
>>
>>  void fdt_fixup_ethernet(void *fdt)
>>  {
>> -       int node, i, j;
>> +       int i, j, prop;
>>         char *tmp, *end;
>>         char mac[16];
>>         const char *path;
>>         unsigned char mac_addr[6];
>>         int offset;
>>
>> -       node = fdt_path_offset(fdt, "/aliases");
>> -       if (node < 0)
>> +       if (fdt_path_offset(fdt, "/aliases") < 0)
>>                 return;
>> -
>> -       for (offset = fdt_first_property_offset(fdt, node);
>> -            offset > 0;
>> -            offset = fdt_next_property_offset(fdt, offset)) {
>> +
>> +       // Cycle through all aliases
>
> Please do not use C++ comment style.

+Joe

>
>> +       for (prop = 0; ; prop++) {
>>                 const char *name;
>>                 int len = strlen("ethernet");
>>
>> +               // FDT might have been edited, recompute the offset
>
> ditto.
>
>> +               offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt,
>> "/aliases"));
>> +               // Select property number 'prop'
>
> ditto.
>
>> +               for (i = 0; i < prop; i++) {
>> +                       offset = fdt_next_property_offset(fdt, offset);
>> +               }
>> +               if (offset < 0)
>> +                       break;
>> +
>>                 path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
>>                 if (!strncmp(name, "ethernet", len)) {
>>                         i = trailing_strtol(name);
>>
>

Regards,
Bin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-04-27  0:06   ` Bin Meng
  2016-04-27  1:57     ` Bin Meng
@ 2016-05-02 16:01     ` Lev Iserovich
  2016-05-03 19:52       ` Joe Hershberger
  1 sibling, 1 reply; 12+ messages in thread
From: Lev Iserovich @ 2016-05-02 16:01 UTC (permalink / raw)
  To: u-boot

Hi,

Updated with C-style comments:

For multiple ethernet interfaces the FDT offset of '/aliases' will 
change as we
are adding MAC addresses to the FDT.
Therefore only the first interface ('ethernet0') will get properly 
updated in
the FDT, with the rest getting FDT errors when we try to set their MAC 
address.

Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
---

Changes in v2:
    - Rebase on u-boot-net patches:
      http://patchwork.ozlabs.org/patch/539373/
      http://patchwork.ozlabs.org/patch/539374/
    - Recompute offset based on property index
    - C-style comments

---

  common/fdt_support.c | 21 ++++++++++++++-------
  1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 48faba9..713d2a4 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -481,23 +481,30 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)

  void fdt_fixup_ethernet(void *fdt)
  {
-       int node, i, j;
+       int i, j, prop;
         char *tmp, *end;
         char mac[16];
         const char *path;
         unsigned char mac_addr[6];
         int offset;

-       node = fdt_path_offset(fdt, "/aliases");
-       if (node < 0)
+       if (fdt_path_offset(fdt, "/aliases") < 0)
                 return;
-
-       for (offset = fdt_first_property_offset(fdt, node);
-            offset > 0;
-            offset = fdt_next_property_offset(fdt, offset)) {
+
+       /* Cycle through all aliases */
+       for (prop = 0; ; prop++) {
                 const char *name;
                 int len = strlen("ethernet");

+               /* FDT might have been edited, recompute the offset */
+               offset = fdt_first_property_offset(fdt, 
fdt_path_offset(fdt, "/aliases"));
+               /* Select property number 'prop' */
+               for (i = 0; i < prop; i++) {
+                       offset = fdt_next_property_offset(fdt, offset);
+               }
+               if (offset < 0)
+                       break;
+
                 path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
                 if (!strncmp(name, "ethernet", len)) {
                         i = trailing_strtol(name);


On 04/26/2016 08:06 PM, Bin Meng wrote:
> Hi Lev,
>
> On Fri, Jan 8, 2016 at 7:04 AM, Lev Iserovich
> <Lev.Iserovich@deshawresearch.com> wrote:
>> For multiple ethernet interfaces the FDT offset of '/aliases' will change as
>> we
>> are adding MAC addresses to the FDT.
>> Therefore only the first interface ('ethernet0') will get properly updated
>> in
>> the FDT, with the rest getting FDT errors when we try to set their MAC
>> address.
>>
>> Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
>> ---
>>
>> Changes in v2:
>>     - Rebase on u-boot-net patches:
>>       http://patchwork.ozlabs.org/patch/539373/
>>       http://patchwork.ozlabs.org/patch/539374/
>>     - Recompute offset based on property index
>>
>> ---
>>
>>   common/fdt_support.c | 21 ++++++++++++++-------
>>   1 file changed, 14 insertions(+), 7 deletions(-)
>>
>> diff --git a/common/fdt_support.c b/common/fdt_support.c
>> index 48faba9..713d2a4 100644
>> --- a/common/fdt_support.c
>> +++ b/common/fdt_support.c
>> @@ -481,23 +481,30 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
>>
>>   void fdt_fixup_ethernet(void *fdt)
>>   {
>> -       int node, i, j;
>> +       int i, j, prop;
>>          char *tmp, *end;
>>          char mac[16];
>>          const char *path;
>>          unsigned char mac_addr[6];
>>          int offset;
>>
>> -       node = fdt_path_offset(fdt, "/aliases");
>> -       if (node < 0)
>> +       if (fdt_path_offset(fdt, "/aliases") < 0)
>>                  return;
>> -
>> -       for (offset = fdt_first_property_offset(fdt, node);
>> -            offset > 0;
>> -            offset = fdt_next_property_offset(fdt, offset)) {
>> +
>> +       // Cycle through all aliases
> Please do not use C++ comment style.
>
>> +       for (prop = 0; ; prop++) {
>>                  const char *name;
>>                  int len = strlen("ethernet");
>>
>> +               // FDT might have been edited, recompute the offset
> ditto.
>
>> +               offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt,
>> "/aliases"));
>> +               // Select property number 'prop'
> ditto.
>
>> +               for (i = 0; i < prop; i++) {
>> +                       offset = fdt_next_property_offset(fdt, offset);
>> +               }
>> +               if (offset < 0)
>> +                       break;
>> +
>>                  path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
>>                  if (!strncmp(name, "ethernet", len)) {
>>                          i = trailing_strtol(name);
>>
> Regards,
> Bin

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-04-27  1:57     ` Bin Meng
@ 2016-05-02 17:12       ` Joe Hershberger
  0 siblings, 0 replies; 12+ messages in thread
From: Joe Hershberger @ 2016-05-02 17:12 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 26, 2016 at 8:57 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Wed, Apr 27, 2016 at 8:06 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Hi Lev,
>>
>> On Fri, Jan 8, 2016 at 7:04 AM, Lev Iserovich
>> <Lev.Iserovich@deshawresearch.com> wrote:
>>> For multiple ethernet interfaces the FDT offset of '/aliases' will change as
>>> we
>>> are adding MAC addresses to the FDT.
>>> Therefore only the first interface ('ethernet0') will get properly updated
>>> in
>>> the FDT, with the rest getting FDT errors when we try to set their MAC
>>> address.
>>>
>>> Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
>>> ---
>>>
>>> Changes in v2:
>>>    - Rebase on u-boot-net patches:
>>>      http://patchwork.ozlabs.org/patch/539373/
>>>      http://patchwork.ozlabs.org/patch/539374/
>>>    - Recompute offset based on property index
>>>
>>> ---
>>>
>>>  common/fdt_support.c | 21 ++++++++++++++-------
>>>  1 file changed, 14 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/common/fdt_support.c b/common/fdt_support.c
>>> index 48faba9..713d2a4 100644
>>> --- a/common/fdt_support.c
>>> +++ b/common/fdt_support.c
>>> @@ -481,23 +481,30 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
>>>
>>>  void fdt_fixup_ethernet(void *fdt)
>>>  {
>>> -       int node, i, j;
>>> +       int i, j, prop;
>>>         char *tmp, *end;
>>>         char mac[16];
>>>         const char *path;
>>>         unsigned char mac_addr[6];
>>>         int offset;
>>>
>>> -       node = fdt_path_offset(fdt, "/aliases");
>>> -       if (node < 0)
>>> +       if (fdt_path_offset(fdt, "/aliases") < 0)
>>>                 return;
>>> -
>>> -       for (offset = fdt_first_property_offset(fdt, node);
>>> -            offset > 0;
>>> -            offset = fdt_next_property_offset(fdt, offset)) {
>>> +
>>> +       // Cycle through all aliases
>>
>> Please do not use C++ comment style.
>
> +Joe

I fixed these in place when applying.

>>
>>> +       for (prop = 0; ; prop++) {
>>>                 const char *name;
>>>                 int len = strlen("ethernet");
>>>
>>> +               // FDT might have been edited, recompute the offset
>>
>> ditto.
>>
>>> +               offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt,
>>> "/aliases"));
>>> +               // Select property number 'prop'
>>
>> ditto.
>>
>>> +               for (i = 0; i < prop; i++) {
>>> +                       offset = fdt_next_property_offset(fdt, offset);
>>> +               }

This is not checkpatch.pl clean either. Fixed when applied.

>>> +               if (offset < 0)
>>> +                       break;
>>> +
>>>                 path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
>>>                 if (!strncmp(name, "ethernet", len)) {
>>>                         i = trailing_strtol(name);
>>>
>>
>
> Regards,
> Bin
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-05-02 16:01     ` Lev Iserovich
@ 2016-05-03 19:52       ` Joe Hershberger
  2016-05-04 14:44         ` Lev Iserovich
  0 siblings, 1 reply; 12+ messages in thread
From: Joe Hershberger @ 2016-05-03 19:52 UTC (permalink / raw)
  To: u-boot

Hi Lev,

On Mon, May 2, 2016 at 11:01 AM, Lev Iserovich
<Lev.Iserovich@deshawresearch.com> wrote:
> Hi,
>
> Updated with C-style comments:
>
> For multiple ethernet interfaces the FDT offset of '/aliases' will change as
> we
> are adding MAC addresses to the FDT.
> Therefore only the first interface ('ethernet0') will get properly updated
> in
> the FDT, with the rest getting FDT errors when we try to set their MAC
> address.
>
> Signed-off-by: Lev Iserovich<iserovil@deshawresearch.com>
> ---
>
> Changes in v2:
>    - Rebase on u-boot-net patches:
>      http://patchwork.ozlabs.org/patch/539373/
>      http://patchwork.ozlabs.org/patch/539374/
>    - Recompute offset based on property index
>    - C-style comments

I had already applied your previous patch with a few minor
adjustments. Please look at what's in my tree and send a patch on top
of that if you care to make further improvements.

Also, you might want to consider using tools/patman/patman when
working on patches and sending to the list.

Thanks,
-Joe

http://git.denx.de/?p=u-boot/u-boot-net.git;a=commitdiff;h=f383f32d5568a3a1a4d31efa97f5cf991961a5e8

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] fdt: fix setting MAC addresses for multiple interfaces
  2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
  2016-04-26 19:27   ` Joe Hershberger
  2016-04-27  0:06   ` Bin Meng
@ 2016-05-03 20:16   ` Joe Hershberger
  2 siblings, 0 replies; 12+ messages in thread
From: Joe Hershberger @ 2016-05-03 20:16 UTC (permalink / raw)
  To: u-boot

Hi Lev,

https://patchwork.ozlabs.org/patch/564594/ was applied to u-boot-net.git.

Thanks!
-Joe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
  2016-05-03 19:52       ` Joe Hershberger
@ 2016-05-04 14:44         ` Lev Iserovich
  0 siblings, 0 replies; 12+ messages in thread
From: Lev Iserovich @ 2016-05-04 14:44 UTC (permalink / raw)
  To: u-boot

Hi Joe,

Thanks for fixing that up, I'll try to stick to patman in the future.

--Lev

On 05/03/2016 03:52 PM, Joe Hershberger wrote:
> Hi Lev,
>
> I had already applied your previous patch with a few minor
> adjustments. Please look at what's in my tree and send a patch on top
> of that if you care to make further improvements.
>
> Also, you might want to consider using tools/patman/patman when
> working on patches and sending to the list.
>
> Thanks,
> -Joe
>
> http://git.denx.de/?p=u-boot/u-boot-net.git;a=commitdiff;h=f383f32d5568a3a1a4d31efa97f5cf991961a5e8

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-05-04 14:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06 21:01 [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces Lev Iserovich
2016-01-07  2:42 ` Bin Meng
2016-01-07 20:21   ` Lev Iserovich
2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
2016-04-26 19:27   ` Joe Hershberger
2016-04-27  0:06   ` Bin Meng
2016-04-27  1:57     ` Bin Meng
2016-05-02 17:12       ` Joe Hershberger
2016-05-02 16:01     ` Lev Iserovich
2016-05-03 19:52       ` Joe Hershberger
2016-05-04 14:44         ` Lev Iserovich
2016-05-03 20:16   ` [U-Boot] " Joe Hershberger

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.