[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCHv2 1/8] lib/fdt: Introduce fdt_getprop_u32_by_offset helper
Hi, On 11/03/2019 09:14, Jia He wrote: From: Jianyong Wu <jianyong.wu@xxxxxxx> This helper will be used very frequcently to u32 from properties. s/frequcently/frequently/ So we provide this helper here to avoid using fdt_getprop and fdt32_to_cpu everywhere. Jira: ENTOS-860 What is it for? Signed-off-by: Wei Chen <wei.chen@xxxxxxx> Signed-off-by: Jianyong Wu <jianyong.wu@xxxxxxx> Signed-off-by: Jia He <justin.he@xxxxxxx> --- lib/fdt/exportsyms.uk | 1 + lib/fdt/fdt_ro.c | 18 ++++++++++++++++++ lib/fdt/include/libfdt.h | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/lib/fdt/exportsyms.uk b/lib/fdt/exportsyms.uk index 2fe4c32..d64d9dc 100644 --- a/lib/fdt/exportsyms.uk +++ b/lib/fdt/exportsyms.uk @@ -60,3 +60,4 @@ fdt_size_cells fdt_stringlist_contains fdt_resize fdt_overlay_apply +fdt_getprop_u32_by_offset diff --git a/lib/fdt/fdt_ro.c b/lib/fdt/fdt_ro.c index 08de2cc..9077cff 100644 --- a/lib/fdt/fdt_ro.c +++ b/lib/fdt/fdt_ro.c @@ -438,6 +438,24 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) return offset; /* error from fdt_next_node() */ }+int fdt_getprop_u32_by_offset(const void *fdt, int offset,+ const char *name, uint32_t *out) +{ + const fdt32_t *prop; + int prop_len; + + prop = fdt_getprop(fdt, offset, name, &prop_len); + if (!prop) + return prop_len; + + if (prop_len >= sizeof(fdt32_t)) { + *out = fdt32_to_cpu(prop[0]); + return 0; + } + + return -FDT_ERR_NOTFOUND; +} + int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, int supernodedepth, int *nodedepth) { diff --git a/lib/fdt/include/libfdt.h b/lib/fdt/include/libfdt.h index 05dedbd..1383f42 100644 --- a/lib/fdt/include/libfdt.h +++ b/lib/fdt/include/libfdt.h @@ -768,6 +768,27 @@ const char *fdt_get_alias(const void *fdt, const char *name); */ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);+/**+ * fdt_getprop_u32_by_offset - retrieve u32 of a given property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to find + * @name: name of the property to find + * @out: pointer to u32 variable (will be overwritten) or NULL + * + * fdt_getprop_u32_by_offset() retrieves u32 to the value of the property + * named 'name' of the node at offset nodeoffset (this will be a + * pointer to within the device blob itself, not a copy of the value). + * If out is non-NULL, the u32 of the property value is returned. + * + * returns: + * 0, on success + * out contains the u32 of a given property at nodeoffset. + * -FDT_ERR_NOTFOUND, node does not have named property + * -FDT_ERR_BADNCELLS, + */ +int fdt_getprop_u32_by_offset(const void *fdt, int nodeoffset, + const char *name, uint32_t *out); + /** * fdt_supernode_atdepth_offset - find a specific ancestor of a node * @fdt: pointer to the device tree blob Cheers, -- Julien Grall _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |