From: gvb.uboot at gmail.com Date: Mon, 6 May 2013 19:31:55 -0400 Subject: [U-Boot] [PATCH 1/5] Export fdt_stringlist_contains() In-Reply-To: <1367883119-25596-1-git-send-email-gvb.uboot@gmail.com> References: <1367883119-25596-1-git-send-email-gvb.uboot@gmail.com> Message-ID: <1367883119-25596-2-git-send-email-gvb.uboot@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Simon Glass This function is useful outside libfdt, so export it. Signed-off-by: Simon Glass Acked-by: David Gibson --- include/libfdt.h | 14 ++++++++++++++ lib/libfdt/fdt_ro.c | 5 ++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/libfdt.h b/include/libfdt.h index fc7f75b..b153cc3 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -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, 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 */ /**********************************************************************/ diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c index 1a461c3..b65f4e2 100644 --- a/lib/libfdt/fdt_ro.c +++ b/lib/libfdt/fdt_ro.c @@ -519,8 +519,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) return offset; /* error from fdt_next_node() */ } -static int _fdt_stringlist_contains(const char *strlist, int listlen, - const char *str) +int fdt_stringlist_contains(const char *strlist, int listlen, const char *str) { int len = strlen(str); const char *p; @@ -546,7 +545,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); if (!prop) return len; - if (_fdt_stringlist_contains(prop, len, compatible)) + if (fdt_stringlist_contains(prop, len, compatible)) return 0; else return 1; -- 1.7.9.5