From: Simon Glass Date: Tue, 11 Nov 2014 17:46:20 +0000 (-0700) Subject: dm: fdt: Correct handling of aliases with embedded digits X-Git-Tag: v2015.01-rc2~4^2~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a88340dfcf8a34cf7fe000c619d01e1d0f0a442a;p=oweals%2Fu-boot.git dm: fdt: Correct handling of aliases with embedded digits 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 Acked-by: Heiko Schocher Reviewed-by: Tom Rini --- diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 9714620ab3..da6ef6b58b 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; }