aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-06-22 02:07:29 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 02:15:15 -0400
commit6d307724cb6a6b8466cad4fdf13d8a409bc2433f (patch)
tree66809731d2a7257f23b8583c69b7bd71a83d634c
parent6760d28bc691bb255c501c9b680f2fc1162258b2 (diff)
[SPARC64]: Add of_getintprop_default().
This encodes a common idiomatic coding pattern used when dealing with integer properties. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc64/kernel/prom.c12
-rw-r--r--include/asm-sparc64/prom.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index fd46e94ce06b..0a32b1064dfb 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -104,6 +104,18 @@ struct property *of_find_property(struct device_node *np, const char *name,
104 return pp; 104 return pp;
105} 105}
106 106
107int of_getintprop_default(struct device_node *np, const char *name, int def)
108{
109 struct property *prop;
110 int len;
111
112 prop = of_find_property(np, name, &len);
113 if (!prop || len != 4)
114 return def;
115
116 return *(int *) prop->value;
117}
118
107static unsigned int prom_early_allocated; 119static unsigned int prom_early_allocated;
108 120
109static void * __init prom_early_alloc(unsigned long size) 121static void * __init prom_early_alloc(unsigned long size)
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h
index eb75d3cbcf4c..d0187b3a0ec3 100644
--- a/include/asm-sparc64/prom.h
+++ b/include/asm-sparc64/prom.h
@@ -82,6 +82,9 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
82extern struct property *of_find_property(struct device_node *np, 82extern struct property *of_find_property(struct device_node *np,
83 const char *name, 83 const char *name,
84 int *lenp); 84 int *lenp);
85extern int of_getintprop_default(struct device_node *np,
86 const char *name,
87 int def);
85 88
86extern void prom_build_devicetree(void); 89extern void prom_build_devicetree(void);
87 90