OF: base: import of_parse_phandle from Linux OF API
This imports of_parse_phandle from Linux OF API. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
This commit is contained in:
parent
1d68e58532
commit
083995f815
|
@ -838,6 +838,29 @@ int of_property_write_u32_array(struct device_node *np,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* of_parse_phandle - Resolve a phandle property to a device_node pointer
|
||||||
|
* @np: Pointer to device node holding phandle property
|
||||||
|
* @phandle_name: Name of property holding a phandle value
|
||||||
|
* @index: For properties holding a table of phandles, this is the index into
|
||||||
|
* the table
|
||||||
|
*
|
||||||
|
* Returns the device_node pointer found or NULL.
|
||||||
|
*/
|
||||||
|
struct device_node *of_parse_phandle(const struct device_node *np,
|
||||||
|
const char *phandle_name, int index)
|
||||||
|
{
|
||||||
|
const __be32 *phandle;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
phandle = of_get_property(np, phandle_name, &size);
|
||||||
|
if ((!phandle) || (size < sizeof(*phandle) * (index + 1)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return of_find_node_by_phandle(be32_to_cpup(phandle + index));
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_parse_phandle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_parse_phandles_with_args - Find a node pointed by phandle in a list
|
* of_parse_phandles_with_args - Find a node pointed by phandle in a list
|
||||||
* @np: pointer to a device tree node containing a list
|
* @np: pointer to a device tree node containing a list
|
||||||
|
|
10
include/of.h
10
include/of.h
|
@ -216,6 +216,10 @@ extern int of_property_match_string(struct device_node *np,
|
||||||
extern int of_property_count_strings(struct device_node *np,
|
extern int of_property_count_strings(struct device_node *np,
|
||||||
const char *propname);
|
const char *propname);
|
||||||
|
|
||||||
|
extern struct device_node *of_parse_phandle(const struct device_node *np,
|
||||||
|
const char *phandle_name,
|
||||||
|
int index);
|
||||||
|
|
||||||
extern void of_alias_scan(void);
|
extern void of_alias_scan(void);
|
||||||
extern int of_alias_get_id(struct device_node *np, const char *stem);
|
extern int of_alias_get_id(struct device_node *np, const char *stem);
|
||||||
extern const char *of_alias_get(struct device_node *np);
|
extern const char *of_alias_get(struct device_node *np);
|
||||||
|
@ -348,6 +352,12 @@ static inline int of_property_count_strings(struct device_node *np,
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct device_node *of_parse_phandle(const struct device_node *np,
|
||||||
|
const char *phandle_name, int index)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct device_node *of_find_node_by_path_from(
|
static inline struct device_node *of_find_node_by_path_from(
|
||||||
struct device_node *from, const char *path)
|
struct device_node *from, const char *path)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue