diff options
Diffstat (limited to 'drivers/of/base.c')
| -rw-r--r-- | drivers/of/base.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 391f91c0bf55..69f85c07d17f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -496,6 +496,30 @@ int of_modalias_node(struct device_node *node, char *modalias, int len) | |||
| 496 | EXPORT_SYMBOL_GPL(of_modalias_node); | 496 | EXPORT_SYMBOL_GPL(of_modalias_node); |
| 497 | 497 | ||
| 498 | /** | 498 | /** |
| 499 | * of_parse_phandle - Resolve a phandle property to a device_node pointer | ||
| 500 | * @np: Pointer to device node holding phandle property | ||
| 501 | * @phandle_name: Name of property holding a phandle value | ||
| 502 | * @index: For properties holding a table of phandles, this is the index into | ||
| 503 | * the table | ||
| 504 | * | ||
| 505 | * Returns the device_node pointer with refcount incremented. Use | ||
| 506 | * of_node_put() on it when done. | ||
| 507 | */ | ||
| 508 | struct device_node * | ||
| 509 | of_parse_phandle(struct device_node *np, const char *phandle_name, int index) | ||
| 510 | { | ||
| 511 | const phandle *phandle; | ||
| 512 | int size; | ||
| 513 | |||
| 514 | phandle = of_get_property(np, phandle_name, &size); | ||
| 515 | if ((!phandle) || (size < sizeof(*phandle) * (index + 1))) | ||
| 516 | return NULL; | ||
| 517 | |||
| 518 | return of_find_node_by_phandle(phandle[index]); | ||
| 519 | } | ||
| 520 | EXPORT_SYMBOL(of_parse_phandle); | ||
| 521 | |||
| 522 | /** | ||
| 499 | * of_parse_phandles_with_args - Find a node pointed by phandle in a list | 523 | * of_parse_phandles_with_args - Find a node pointed by phandle in a list |
| 500 | * @np: pointer to a device tree node containing a list | 524 | * @np: pointer to a device tree node containing a list |
| 501 | * @list_name: property name that contains a list | 525 | * @list_name: property name that contains a list |
