diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-06-22 08:07:29 +0200 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-06-24 08:15:15 +0200 |
commit | 6d307724cb6a6b8466cad4fdf13d8a409bc2433f (patch) | |
tree | 66809731d2a7257f23b8583c69b7bd71a83d634c /arch | |
parent | [SPARC64]: Convert sun4v virtual-device layer to in-kernel PROM device tree. (diff) | |
download | linux-6d307724cb6a6b8466cad4fdf13d8a409bc2433f.tar.xz linux-6d307724cb6a6b8466cad4fdf13d8a409bc2433f.zip |
[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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/kernel/prom.c | 12 |
1 files changed, 12 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, 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) |