ia64/xen-unstable

changeset 11522:96f4d3e1bc98

[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@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Thu Sep 14 11:11:00 2006 -0400 (2006-09-14)
parents 8ca32cdc9841
children e99a195f2112
files xen/arch/powerpc/dart.c xen/arch/powerpc/of-devtree.h
line diff
     1.1 --- a/xen/arch/powerpc/dart.c	Thu Sep 14 10:20:16 2006 -0400
     1.2 +++ b/xen/arch/powerpc/dart.c	Thu Sep 14 11:11:00 2006 -0400
     1.3 @@ -207,16 +207,17 @@ static int find_dart(struct dart_info *d
     1.4      if (rc <= 0)
     1.5          return -1;
     1.6  
     1.7 -    di->di_base = DART_DEF_BASE;
     1.8 -
     1.9 -    if (strstr(compat, "u3")) {
    1.10 +    if (ofd_strstr(compat, rc, "u4"))
    1.11 +        di->di_model = DART_U4;
    1.12 +    else if (ofd_strstr(compat, rc, "u3"))
    1.13          di->di_model = DART_U3;
    1.14 -    } else if (strstr(compat, "u4")) {
    1.15 -        di->di_model = DART_U4;
    1.16 -    } else {
    1.17 +    else {
    1.18          DBG("%s: not a U3 or U4\n", __func__);
    1.19          return -1;
    1.20      }
    1.21 +        
    1.22 +    di->di_base = DART_DEF_BASE;
    1.23 +
    1.24      /* FIXME: this should actually be the HT reg value */
    1.25      di->di_window.dw_liobn = 0;
    1.26      di->di_window.dw_base_hi = 0;
     2.1 --- a/xen/arch/powerpc/of-devtree.h	Thu Sep 14 10:20:16 2006 -0400
     2.2 +++ b/xen/arch/powerpc/of-devtree.h	Thu Sep 14 11:11:00 2006 -0400
     2.3 @@ -136,4 +136,20 @@ extern ofdn_t ofd_node_find_next(void *m
     2.4  extern ofdn_t ofd_node_find_prev(void *mem, ofdn_t n);
     2.5  extern void ofd_init(int (*write)(const char *, size_t len));
     2.6  
     2.7 +static inline int ofd_strstr(const char *s, int len, const char *str)
     2.8 +{
     2.9 +    int l = strlen(str);
    2.10 +    do {
    2.11 +        int n;
    2.12 +
    2.13 +        if (len >= l && strstr(s, str))
    2.14 +            return 1;
    2.15 +
    2.16 +        n = strnlen(s, len) + 1;
    2.17 +        len -= strnlen(s, len) + 1;
    2.18 +        s += n;
    2.19 +    } while (len > 0);
    2.20 +    return 0;
    2.21 +}
    2.22 +
    2.23  #endif /* _OF_DEVTREE_H */