提交 6d307724 编写于 作者: D David S. Miller

[SPARC64]: Add of_getintprop_default().

This encodes a common idiomatic coding pattern used when
dealing with integer properties.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6760d28b
...@@ -104,6 +104,18 @@ struct property *of_find_property(struct device_node *np, const char *name, ...@@ -104,6 +104,18 @@ struct property *of_find_property(struct device_node *np, const char *name,
return pp; 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 unsigned int prom_early_allocated;
static void * __init prom_early_alloc(unsigned long size) static void * __init prom_early_alloc(unsigned long size)
......
...@@ -82,6 +82,9 @@ extern struct device_node *of_get_next_child(const struct device_node *node, ...@@ -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, extern struct property *of_find_property(struct device_node *np,
const char *name, const char *name,
int *lenp); int *lenp);
extern int of_getintprop_default(struct device_node *np,
const char *name,
int def);
extern void prom_build_devicetree(void); extern void prom_build_devicetree(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册