From b0e398123b9345faf6d01855aa621af0815ad497 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 22 Jun 2006 22:08:58 -0700 Subject: [PATCH] --- yaml --- r: 29567 b: refs/heads/master c: 8cd24ed4f8031636fb5dacb04adee9e02556ecd5 h: refs/heads/master i: 29565: 60a469e2fe4a487d91804c8d1010f362b8f90acc 29563: 10b06e0da3611903b2d447042445b2278dc360c2 29559: 2f2a0338345f0390fa23ac63307ca2e7582d111c 29551: c4bedd464c04b4814ade152b472d6d321c12f7c0 29535: 04bf44d71e65d56f7e625314da42effe7d2dbaf5 29503: e9f89f284dd01e14e2c2bdc46030272d2304bcb7 29439: d7a8cd60ba761d03273c6864907ed2a4cd107b25 v: v3 --- [refs] | 2 +- trunk/arch/sparc64/kernel/prom.c | 43 ++++++++++++++++++++++++++++++++ trunk/include/asm-sparc64/prom.h | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 25a7cc4197bd..08eaae2306e9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 92c4e22593c22eb0943b232c61c98b517081637d +refs/heads/master: 8cd24ed4f8031636fb5dacb04adee9e02556ecd5 diff --git a/trunk/arch/sparc64/kernel/prom.c b/trunk/arch/sparc64/kernel/prom.c index 7809100034b0..e9d703eea806 100644 --- a/trunk/arch/sparc64/kernel/prom.c +++ b/trunk/arch/sparc64/kernel/prom.c @@ -27,6 +27,26 @@ static struct device_node *allnodes; +int of_device_is_compatible(struct device_node *device, const char *compat) +{ + const char* cp; + int cplen, l; + + cp = (char *) of_get_property(device, "compatible", &cplen); + if (cp == NULL) + return 0; + while (cplen > 0) { + if (strncmp(cp, compat, strlen(compat)) == 0) + return 1; + l = strlen(cp) + 1; + cp += l; + cplen -= l; + } + + return 0; +} +EXPORT_SYMBOL(of_device_is_compatible); + struct device_node *of_get_parent(const struct device_node *node) { struct device_node *np; @@ -38,6 +58,7 @@ struct device_node *of_get_parent(const struct device_node *node) return np; } +EXPORT_SYMBOL(of_get_parent); struct device_node *of_get_next_child(const struct device_node *node, struct device_node *prev) @@ -51,6 +72,7 @@ struct device_node *of_get_next_child(const struct device_node *node, return next; } +EXPORT_SYMBOL(of_get_next_child); struct device_node *of_find_node_by_path(const char *path) { @@ -75,6 +97,7 @@ struct device_node *of_find_node_by_phandle(phandle handle) return np; } +EXPORT_SYMBOL(of_find_node_by_phandle); struct device_node *of_find_node_by_name(struct device_node *from, const char *name) @@ -88,6 +111,7 @@ struct device_node *of_find_node_by_name(struct device_node *from, return np; } +EXPORT_SYMBOL(of_find_node_by_name); struct device_node *of_find_node_by_type(struct device_node *from, const char *type) @@ -101,6 +125,25 @@ struct device_node *of_find_node_by_type(struct device_node *from, return np; } +EXPORT_SYMBOL(of_find_node_by_type); + +struct device_node *of_find_compatible_node(struct device_node *from, + const char *type, const char *compatible) +{ + struct device_node *np; + + np = from ? from->allnext : allnodes; + for (; np != 0; np = np->allnext) { + if (type != NULL + && !(np->type != 0 && strcmp(np->type, type) == 0)) + continue; + if (of_device_is_compatible(np, compatible)) + break; + } + + return np; +} +EXPORT_SYMBOL(of_find_compatible_node); struct property *of_find_property(struct device_node *np, const char *name, int *lenp) diff --git a/trunk/include/asm-sparc64/prom.h b/trunk/include/asm-sparc64/prom.h index 062ae6e1212e..6d1556c0c263 100644 --- a/trunk/include/asm-sparc64/prom.h +++ b/trunk/include/asm-sparc64/prom.h @@ -75,6 +75,8 @@ extern struct device_node *of_find_node_by_type(struct device_node *from, #define for_each_node_by_type(dn, type) \ for (dn = of_find_node_by_type(NULL, type); dn; \ dn = of_find_node_by_type(dn, type)) +extern struct device_node *of_find_compatible_node(struct device_node *from, + const char *type, const char *compat); extern struct device_node *of_find_node_by_path(const char *path); extern struct device_node *of_find_node_by_phandle(phandle handle); extern struct device_node *of_get_parent(const struct device_node *node); @@ -83,6 +85,7 @@ extern struct device_node *of_get_next_child(const struct device_node *node, extern struct property *of_find_property(struct device_node *np, const char *name, int *lenp); +extern int of_device_is_compatible(struct device_node *device, const char *); extern void *of_get_property(struct device_node *node, const char *name, int *lenp); extern int of_getintprop_default(struct device_node *np,