Skip to content

Commit 83b34af

Browse files
Heikki Krogerusrafaeljw
authored andcommitted
device property: Introduce fwnode_find_reference()
In most cases the references that the drivers look for don't have any arguments. This introduces a wrapper function for fwnode_property_get_reference_args() that looks for references by using only the name and index. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent ee48cef commit 83b34af

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

drivers/base/property.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,30 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
484484
}
485485
EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);
486486

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+
487511
/**
488512
* device_remove_properties - Remove properties from a device object.
489513
* @dev: Device whose properties to remove.

include/linux/property.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
7979
unsigned int nargs, unsigned int index,
8080
struct fwnode_reference_args *args);
8181

82+
struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
83+
const char *name,
84+
unsigned int index);
85+
8286
struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
8387
struct fwnode_handle *fwnode_get_next_parent(
8488
struct fwnode_handle *fwnode);

0 commit comments

Comments
 (0)