WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [POWERPC][XEN] add ofd_strstr() that chec

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 19 Sep 2006 10:03:27 +0000
Delivery-date: Tue, 19 Sep 2006 03:06:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property, Xen patchbot-unstable <=