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-ppc-devel

[XenPPC] [xenppc-unstable] [POWERPC][XEN] add ofd_strstr() that checks a

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Sep 2006 15:20:38 +0000
Delivery-date: Thu, 14 Sep 2006 08:59:08 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# 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

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