Skip to contentSkip to conversation

fdt_support: Fixup 'ethernet' aliases not ending in digits

PATCH In review Tuomas Tynkkynen 4 participants 4 messages Mar 20, 2017 – Mar 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fdt_support: Fixup 'ethernet' aliases not ending in digits

The Raspberry Pi device tree files since Linux v4.9 have a "ethernet" alias pointing to the on-board Ethernet device node. However, U-Boot's fdt_fixup_ethernet() only looks at ethernet aliases ending in digits.

As the spec doesn't mandate that aliases must end in numbers and there have been much older uses of an "ethernet" aliases in the wild (according to Tom Rini), change the code to accept "ethernet" as well.

Without this Linux isn't told of the MAC address provided by the RPI firmware and the ethernet interface is always assigned a random MAC address.

---
v2: Change code & commit messages to imply that plain 'ethernet' usage
is not a bug in the DT, kill the 'len' variable.

 common/fdt_support.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
common/fdt_support.c +7 -3
index 55d4d6f6d4..c6a76b7ad2 100644
@@ -482,7 +482,6 @@ void fdt_fixup_ethernet(void *fdt)
 	/* 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,
@@ -495,8 +494,13 @@ void fdt_fixup_ethernet(void *fdt)
 			break;
 
 		path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
-		if (!strncmp(name, "ethernet", len)) {
-			i = trailing_strtol(name);
+		if (!strncmp(name, "ethernet", 8)) {
+			/* Treat plain "ethernet" same as "ethernet0". */
+			if (!strcmp(name, "ethernet"))
+				i = 0;
+			else
+				i = trailing_strtol(name);
+
 			if (i != -1) {
 				if (i == 0)
 					strcpy(mac, "ethaddr");
Signature · 1 line
2.11.1
#1 lore raw

PATCH v2 1/1 fdt_support: Fixup 'ethernet' aliases not ending in digits

Quoted 9 lines · Tuomas Tynkkynen

The Raspberry Pi device tree files since Linux v4.9 have a "ethernet" alias pointing to the on-board Ethernet device node. However, U-Boot's fdt_fixup_ethernet() only looks at ethernet aliases ending in digits.

As the spec doesn't mandate that aliases must end in numbers and there have been much older uses of an "ethernet" aliases in the wild (according to Tom Rini), change the code to accept "ethernet" as well.

Quoted 5 lines

Without this Linux isn't told of the MAC address provided by the RPI firmware and the ethernet interface is always assigned a random MAC address.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170320/db3b241f/attachment.sig>
#2 lore raw

PATCH v2 1/1 fdt_support: Fixup 'ethernet' aliases not ending in digits

In reply to Tuomas Tynkkynen
Quoted 9 lines · Tuomas Tynkkynen

The Raspberry Pi device tree files since Linux v4.9 have a "ethernet" alias pointing to the on-board Ethernet device node. However, U-Boot's fdt_fixup_ethernet() only looks at ethernet aliases ending in digits.

As the spec doesn't mandate that aliases must end in numbers and there have been much older uses of an "ethernet" aliases in the wild (according to Tom Rini), change the code to accept "ethernet" as well.

Quoted 5 lines

Without this Linux isn't told of the MAC address provided by the RPI firmware and the ethernet interface is always assigned a random MAC address.