summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-11-11 10:46:20 -0700
committerSimon Glass <sjg@chromium.org>2014-11-22 10:16:47 +0100
commita88340dfcf8a34cf7fe000c619d01e1d0f0a442a (patch)
tree9c59ee715a5c1e2b9efe0453a71f65041e631eaf
parent479728cb0c752a121e0fd84c6c6d74e93e086905 (diff)
downloadu-boot-imx-a88340dfcf8a34cf7fe000c619d01e1d0f0a442a.zip
u-boot-imx-a88340dfcf8a34cf7fe000c619d01e1d0f0a442a.tar.gz
u-boot-imx-a88340dfcf8a34cf7fe000c619d01e1d0f0a442a.tar.bz2
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 <sjg@chromium.org> Acked-by: Heiko Schocher <hs@denx.de> Reviewed-by: Tom Rini <trini@ti.com>
-rw-r--r--lib/fdtdec.c6
1 files 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;
}