Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
[firefly-linux-kernel-4.4.55.git] / drivers / of / base.c
index 580644986945cb704d94de09bb602848fd13aede..d9bfd49b193503f61977a7a1c253e0a981ba07b1 100644 (file)
@@ -1260,3 +1260,44 @@ int of_alias_get_id(struct device_node *np, const char *stem)
        return id;
 }
 EXPORT_SYMBOL_GPL(of_alias_get_id);
+
+const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
+                              u32 *pu)
+{
+       const void *curv = cur;
+
+       if (!prop)
+               return NULL;
+
+       if (!cur) {
+               curv = prop->value;
+               goto out_val;
+       }
+
+       curv += sizeof(*cur);
+       if (curv >= prop->value + prop->length)
+               return NULL;
+
+out_val:
+       *pu = be32_to_cpup(curv);
+       return curv;
+}
+EXPORT_SYMBOL_GPL(of_prop_next_u32);
+
+const char *of_prop_next_string(struct property *prop, const char *cur)
+{
+       const void *curv = cur;
+
+       if (!prop)
+               return NULL;
+
+       if (!cur)
+               return prop->value;
+
+       curv += strlen(cur) + 1;
+       if (curv >= prop->value + prop->length)
+               return NULL;
+
+       return curv;
+}
+EXPORT_SYMBOL_GPL(of_prop_next_string);