From: David S. Miller Date: Thu, 22 Jun 2006 06:07:29 +0000 (-0700) Subject: [SPARC64]: Add of_getintprop_default(). X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6d307724cb6a6b8466cad4fdf13d8a409bc2433f;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git [SPARC64]: Add of_getintprop_default(). This encodes a common idiomatic coding pattern used when dealing with integer properties. Signed-off-by: David S. Miller --- 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) 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, 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);