]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SPARC64]: Add of_getintprop_default().
authorDavid S. Miller <davem@sunset.davemloft.net>
Thu, 22 Jun 2006 06:07:29 +0000 (23:07 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sat, 24 Jun 2006 06:15:15 +0000 (23:15 -0700)
This encodes a common idiomatic coding pattern used when
dealing with integer properties.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/kernel/prom.c
include/asm-sparc64/prom.h

index fd46e94ce06b114b5dfe708278c5dc29fa8bc17b..0a32b1064dfbf51b92edf070e35d983228909175 100644 (file)
@@ -104,6 +104,18 @@ struct property *of_find_property(struct device_node *np, const char *name,
        return pp;
 }
 
+int of_getintprop_default(struct device_node *np, const char *name, int def)
+{
+       struct property *prop;
+       int len;
+
+       prop = of_find_property(np, name, &len);
+       if (!prop || len != 4)
+               return def;
+
+       return *(int *) prop->value;
+}
+
 static unsigned int prom_early_allocated;
 
 static void * __init prom_early_alloc(unsigned long size)
index eb75d3cbcf4cd84ec426d39d104ec0ac9f92074d..d0187b3a0ec39607c058836c2effc2e505340e5b 100644 (file)
@@ -82,6 +82,9 @@ 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_getintprop_default(struct device_node *np,
+                                const char *name,
+                                int def);
 
 extern void prom_build_devicetree(void);