summaryrefslogtreecommitdiff
path: root/lib/fdtdec.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-02-11 11:15:34 -0500
committerTom Rini <trini@konsulko.com>2019-02-11 11:15:34 -0500
commitf94fa0e94f36c740d3c7aa314c89a750c742185b (patch)
tree42077386d60386628bed02011566ddf990913eb8 /lib/fdtdec.c
parentf49929772c5ea22e4af987bfb1e5ae13e9895093 (diff)
parentc4bd12a7dad43ed9de3070c7c5e8b690d8c03a79 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-i2c
- DM I2C improvements
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r--lib/fdtdec.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index fd0ad6ea84..09a7e133a5 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -542,6 +542,39 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
return -ENOENT;
}
+int fdtdec_get_alias_highest_id(const void *blob, const char *base)
+{
+ int base_len = strlen(base);
+ int prop_offset;
+ int aliases;
+ int max = -1;
+
+ debug("Looking for highest alias id for '%s'\n", base);
+
+ aliases = fdt_path_offset(blob, "/aliases");
+ for (prop_offset = fdt_first_property_offset(blob, aliases);
+ prop_offset > 0;
+ prop_offset = fdt_next_property_offset(blob, prop_offset)) {
+ const char *prop;
+ const char *name;
+ int len, val;
+
+ prop = fdt_getprop_by_offset(blob, prop_offset, &name, &len);
+ debug(" - %s, %s\n", name, prop);
+ if (*prop != '/' || prop[len - 1] ||
+ strncmp(name, base, base_len))
+ continue;
+
+ val = trailing_strtol(name);
+ if (val > max) {
+ debug("Found seq %d\n", val);
+ max = val;
+ }
+ }
+
+ return max;
+}
+
const char *fdtdec_get_chosen_prop(const void *blob, const char *name)
{
int chosen_node;