[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property
# HG changeset patch # User Jimi Xenidis <jimix@xxxxxxxxxxxxxx> # Node ID 96f4d3e1bc98a9f7f70f1bfd1695a529962b5e26 # Parent 8ca32cdc98410d1aa94952f6c6db0cb1a4456d35 [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property Some OF properties can have a list of '\0' terminated strings, we frequently need to strstr against all of them. Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx> Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx> --- xen/arch/powerpc/dart.c | 17 +++++++++-------- xen/arch/powerpc/of-devtree.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff -r 8ca32cdc9841 -r 96f4d3e1bc98 xen/arch/powerpc/dart.c --- a/xen/arch/powerpc/dart.c Thu Sep 14 10:20:16 2006 -0400 +++ b/xen/arch/powerpc/dart.c Thu Sep 14 11:11:00 2006 -0400 @@ -207,16 +207,17 @@ static int find_dart(struct dart_info *d if (rc <= 0) return -1; + if (ofd_strstr(compat, rc, "u4")) + di->di_model = DART_U4; + else if (ofd_strstr(compat, rc, "u3")) + di->di_model = DART_U3; + else { + DBG("%s: not a U3 or U4\n", __func__); + return -1; + } + di->di_base = DART_DEF_BASE; - if (strstr(compat, "u3")) { - di->di_model = DART_U3; - } else if (strstr(compat, "u4")) { - di->di_model = DART_U4; - } else { - DBG("%s: not a U3 or U4\n", __func__); - return -1; - } /* FIXME: this should actually be the HT reg value */ di->di_window.dw_liobn = 0; di->di_window.dw_base_hi = 0; diff -r 8ca32cdc9841 -r 96f4d3e1bc98 xen/arch/powerpc/of-devtree.h --- a/xen/arch/powerpc/of-devtree.h Thu Sep 14 10:20:16 2006 -0400 +++ b/xen/arch/powerpc/of-devtree.h Thu Sep 14 11:11:00 2006 -0400 @@ -136,4 +136,20 @@ extern ofdn_t ofd_node_find_prev(void *m extern ofdn_t ofd_node_find_prev(void *mem, ofdn_t n); extern void ofd_init(int (*write)(const char *, size_t len)); +static inline int ofd_strstr(const char *s, int len, const char *str) +{ + int l = strlen(str); + do { + int n; + + if (len >= l && strstr(s, str)) + return 1; + + n = strnlen(s, len) + 1; + len -= strnlen(s, len) + 1; + s += n; + } while (len > 0); + return 0; +} + #endif /* _OF_DEVTREE_H */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |