]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: fdt: Correct handling of aliases with embedded digits
authorSimon Glass <sjg@chromium.org>
Tue, 11 Nov 2014 17:46:20 +0000 (10:46 -0700)
committerSimon Glass <sjg@chromium.org>
Sat, 22 Nov 2014 09:16:47 +0000 (10:16 +0100)
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@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Tom Rini <trini@ti.com>
lib/fdtdec.c

index 9714620ab3e211df006d440dc4f1abb6d03bb9b8..da6ef6b58bdd84734adb7bd7e1ea172e34aae83a 100644 (file)
@@ -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;
                        }