# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID a1beb7b142226b2d00af68806e02cba6100e6aa3
# Parent 164572d15e60079b8fe93b0f675312f5553c7163
[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>
---
xen/arch/powerpc/dart.c | 17 +++++++++--------
xen/arch/powerpc/of-devtree.h | 16 ++++++++++++++++
2 files changed, 25 insertions(+), 8 deletions(-)
diff -r 164572d15e60 -r a1beb7b14222 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 164572d15e60 -r a1beb7b14222 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-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|