diff options
-rw-r--r-- | drivers/base/property.c | 24 | ||||
-rw-r--r-- | include/linux/property.h | 4 |
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index 348b37e64944..81bd01ed4042 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c | |||
@@ -485,6 +485,30 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, | |||
485 | EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args); | 485 | EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args); |
486 | 486 | ||
487 | /** | 487 | /** |
488 | * fwnode_find_reference - Find named reference to a fwnode_handle | ||
489 | * @fwnode: Firmware node where to look for the reference | ||
490 | * @name: The name of the reference | ||
491 | * @index: Index of the reference | ||
492 | * | ||
493 | * @index can be used when the named reference holds a table of references. | ||
494 | * | ||
495 | * Returns pointer to the reference fwnode, or ERR_PTR. Caller is responsible to | ||
496 | * call fwnode_handle_put() on the returned fwnode pointer. | ||
497 | */ | ||
498 | struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, | ||
499 | const char *name, | ||
500 | unsigned int index) | ||
501 | { | ||
502 | struct fwnode_reference_args args; | ||
503 | int ret; | ||
504 | |||
505 | ret = fwnode_property_get_reference_args(fwnode, name, NULL, 0, index, | ||
506 | &args); | ||
507 | return ret ? ERR_PTR(ret) : args.fwnode; | ||
508 | } | ||
509 | EXPORT_SYMBOL_GPL(fwnode_find_reference); | ||
510 | |||
511 | /** | ||
488 | * device_remove_properties - Remove properties from a device object. | 512 | * device_remove_properties - Remove properties from a device object. |
489 | * @dev: Device whose properties to remove. | 513 | * @dev: Device whose properties to remove. |
490 | * | 514 | * |
diff --git a/include/linux/property.h b/include/linux/property.h index abcde2f236a0..088d4db7e949 100644 --- a/include/linux/property.h +++ b/include/linux/property.h | |||
@@ -79,6 +79,10 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, | |||
79 | unsigned int nargs, unsigned int index, | 79 | unsigned int nargs, unsigned int index, |
80 | struct fwnode_reference_args *args); | 80 | struct fwnode_reference_args *args); |
81 | 81 | ||
82 | struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, | ||
83 | const char *name, | ||
84 | unsigned int index); | ||
85 | |||
82 | struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); | 86 | struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); |
83 | struct fwnode_handle *fwnode_get_next_parent( | 87 | struct fwnode_handle *fwnode_get_next_parent( |
84 | struct fwnode_handle *fwnode); | 88 | struct fwnode_handle *fwnode); |