Skip to content
Snippets Groups Projects
Commit e853b324 authored by Simon Glass's avatar Simon Glass Committed by Gerald Van Baren
Browse files

Export fdt_stringlist_contains()


This function is useful outside libfdt, so export it.

Ref: DTC commit b7aa300e

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent 2988eac7
No related branches found
No related tags found
No related merge requests found
...@@ -816,6 +816,20 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, ...@@ -816,6 +816,20 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
int fdt_node_offset_by_compatible(const void *fdt, int startoffset, int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
const char *compatible); const char *compatible);
/**
* fdt_stringlist_contains - check a string list property for a string
* @strlist: Property containing a list of strings to check
* @listlen: Length of property
* @str: String to search for
*
* This is a utility function provided for convenience. The list contains
* one or more strings, each terminated by \0, as is found in a device tree
* "compatible" property.
*
* @return: 1 if the string is found in the list, 0 not found, or invalid list
*/
int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
/**********************************************************************/ /**********************************************************************/
/* Write-in-place functions */ /* Write-in-place functions */
/**********************************************************************/ /**********************************************************************/
......
...@@ -519,8 +519,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) ...@@ -519,8 +519,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
return offset; /* error from fdt_next_node() */ return offset; /* error from fdt_next_node() */
} }
static int _fdt_stringlist_contains(const char *strlist, int listlen, int fdt_stringlist_contains(const char *strlist, int listlen, const char *str)
const char *str)
{ {
int len = strlen(str); int len = strlen(str);
const char *p; const char *p;
...@@ -546,7 +545,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, ...@@ -546,7 +545,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); prop = fdt_getprop(fdt, nodeoffset, "compatible", &len);
if (!prop) if (!prop)
return len; return len;
if (_fdt_stringlist_contains(prop, len, compatible)) if (fdt_stringlist_contains(prop, len, compatible))
return 0; return 0;
else else
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment