]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sparc/kernel/prom.c
[PATCH] i386: get rid of unused variables
[linux-2.6-omap-h63xx.git] / arch / sparc / kernel / prom.c
index 4b06dcb00ebde6212caafa0ff47989f86ce57f7e..eed140b3c7397caf4abe0bd204df9bbb45dd25df 100644 (file)
@@ -32,12 +32,13 @@ static struct device_node *allnodes;
  */
 static DEFINE_RWLOCK(devtree_lock);
 
-int of_device_is_compatible(struct device_node *device, const char *compat)
+int of_device_is_compatible(const struct device_node *device,
+                           const char *compat)
 {
        const char* cp;
        int cplen, l;
 
-       cp = (char *) of_get_property(device, "compatible", &cplen);
+       cp = of_get_property(device, "compatible", &cplen);
        if (cp == NULL)
                return 0;
        while (cplen > 0) {
@@ -150,13 +151,14 @@ struct device_node *of_find_compatible_node(struct device_node *from,
 }
 EXPORT_SYMBOL(of_find_compatible_node);
 
-struct property *of_find_property(struct device_node *np, const char *name,
+struct property *of_find_property(const struct device_node *np,
+                                 const char *name,
                                  int *lenp)
 {
        struct property *pp;
 
        for (pp = np->properties; pp != 0; pp = pp->next) {
-               if (strcmp(pp->name, name) == 0) {
+               if (strcasecmp(pp->name, name) == 0) {
                        if (lenp != 0)
                                *lenp = pp->length;
                        break;
@@ -170,7 +172,8 @@ EXPORT_SYMBOL(of_find_property);
  * Find a property with a given name for a given node
  * and return the value.
  */
-void *of_get_property(struct device_node *np, const char *name, int *lenp)
+const void *of_get_property(const struct device_node *np, const char *name,
+                           int *lenp)
 {
        struct property *pp = of_find_property(np,name,lenp);
        return pp ? pp->value : NULL;
@@ -192,7 +195,7 @@ EXPORT_SYMBOL(of_getintprop_default);
 
 int of_n_addr_cells(struct device_node *np)
 {
-       int* ip;
+       const int* ip;
        do {
                if (np->parent)
                        np = np->parent;
@@ -207,7 +210,7 @@ EXPORT_SYMBOL(of_n_addr_cells);
 
 int of_n_size_cells(struct device_node *np)
 {
-       int* ip;
+       const int* ip;
        do {
                if (np->parent)
                        np = np->parent;
@@ -239,11 +242,11 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
        while (*prevp) {
                struct property *prop = *prevp;
 
-               if (!strcmp(prop->name, name)) {
+               if (!strcasecmp(prop->name, name)) {
                        void *old_val = prop->value;
                        int ret;
 
-                       ret = prom_setprop(dp->node, name, val, len);
+                       ret = prom_setprop(dp->node, (char *) name, val, len);
                        err = -EINVAL;
                        if (ret >= 0) {
                                prop->value = new_val;
@@ -444,6 +447,7 @@ static struct property * __init build_one_prop(phandle node, char *prev, char *s
        static struct property *tmp = NULL;
        struct property *p;
        int len;
+       const char *name;
 
        if (tmp) {
                p = tmp;
@@ -456,25 +460,30 @@ static struct property * __init build_one_prop(phandle node, char *prev, char *s
 
        p->name = (char *) (p + 1);
        if (special_name) {
+               strcpy(p->name, special_name);
                p->length = special_len;
                p->value = prom_early_alloc(special_len);
                memcpy(p->value, special_val, special_len);
        } else {
                if (prev == NULL) {
-                       prom_firstprop(node, p->name);
+                       name = prom_firstprop(node, NULL);
                } else {
-                       prom_nextprop(node, prev, p->name);
+                       name = prom_nextprop(node, prev, NULL);
                }
-               if (strlen(p->name) == 0) {
+               if (strlen(name) == 0) {
                        tmp = p;
                        return NULL;
                }
+               strcpy(p->name, name);
                p->length = prom_getproplen(node, p->name);
                if (p->length <= 0) {
                        p->length = 0;
                } else {
                        p->value = prom_early_alloc(p->length + 1);
-                       prom_getproperty(node, p->name, p->value, p->length);
+                       len = prom_getproperty(node, p->name, p->value,
+                                              p->length);
+                       if (len <= 0)
+                               p->length = 0;
                        ((unsigned char *)p->value)[p->length] = '\0';
                }
        }