[U-Boot] [PATCH v2 04/17] dm: fdt: Correct handling of aliases with embedded digits

Simon Glass sjg at chromium.org
Tue Nov 11 18:46:20 CET 2014


Since we scan from left to right looking for the first digit, "i2c0" returns
2 instead of 0 for the alias number. Adjust the code to scan from right to
left instead.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Add new patch to correct handling of aliases with embedded digits

 lib/fdtdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 9714620..da6ef6b 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -355,9 +355,9 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
 		slash = strrchr(prop, '/');
 		if (strcmp(slash + 1, find_name))
 			continue;
-		for (p = name; *p; p++) {
-			if (isdigit(*p)) {
-				*seqp = simple_strtoul(p, NULL, 10);
+		for (p = name + strlen(name) - 1; p > name; p--) {
+			if (!isdigit(*p)) {
+				*seqp = simple_strtoul(p + 1, NULL, 10);
 				debug("Found seq %d\n", *seqp);
 				return 0;
 			}
-- 
2.1.0.rc2.206.gedb03e5



More information about the U-Boot mailing list