From 32c6a8e1f803e2a42fa7bf76f23231736841bfc0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 23 Oct 2021 17:26:06 -0600 Subject: dm: core: Fix up string-function documentation The details for of_property_read_string_helper() and ofnode_read_string_index() are a little inaccurate. Fix up the comments to avoid confusion. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/dm/ofnode.h') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 0f680e5aa62..0eae8f9a813 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -590,11 +590,11 @@ int ofnode_stringlist_search(ofnode node, const char *propname, * * @node: node to check * @propname: name of the property containing the string list - * @index: index of the string to return + * @index: index of the string to return (cannot be negative) * @lenp: return location for the string length or an error code on failure * * @return: - * length of string, if found or -ve error value if not found + * 0 if found or -ve error value if not found */ int ofnode_read_string_index(ofnode node, const char *propname, int index, const char **outp); -- cgit v1.2.3 From 075bfc9575aedca15e61f5f1cfa300409e2979fe Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 23 Oct 2021 17:26:07 -0600 Subject: dm: core: Add a way to obtain a string list At present we support reading a string list a string at a time. Apart from being inefficient, this makes it impossible to separate reading of the devicetree into the of_to_plat() method where it belongs, since any code which needs access to the string must read it from the devicetree. Add a function which returns the string property as an array of pointers to the strings, which is easily used by clients. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/dm/ofnode.h') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 0eae8f9a813..6601bd83189 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -609,6 +609,26 @@ int ofnode_read_string_index(ofnode node, const char *propname, int index, */ int ofnode_read_string_count(ofnode node, const char *property); +/** + * ofnode_read_string_list() - read a list of strings + * + * This produces a list of string pointers with each one pointing to a string + * in the string list. If the property does not exist, it returns {NULL}. + * + * The data is allocated and the caller is reponsible for freeing the return + * value (the list of string pointers). The strings themselves may not be + * changed as they point directly into the devicetree property. + * + * @node: node to check + * @listp: returns an allocated, NULL-terminated list of strings if the return + * value is > 0, else is set to NULL + * @return number of strings in list, 0 if none, -ENOMEM if out of memory, + * -EINVAL if no such property, -EENODATA if property is empty + * @return: NULL-terminated list of strings (NULL if no property or empty) + */ +int ofnode_read_string_list(ofnode node, const char *property, + const char ***listp); + /** * ofnode_parse_phandle_with_args() - Find a node pointed by phandle in a list * -- cgit v1.2.3