device property: Introduce fwnode_property_get_reference_args

The new fwnode_property_get_reference_args() interface amends the fwnode
property API with the functionality of both of_parse_phandle_with_args()
and __acpi_node_get_property_reference().

The semantics is slightly different: the cells property is ignored on ACPI
as the number of arguments can be explicitly obtained from the firmware
interface.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Sakari Ailus
2017-07-21 15:11:49 +03:00
committed by Rafael J. Wysocki
parent 37ba983cfb
commit 3e3119d308
5 changed files with 109 additions and 0 deletions

View File

@@ -33,6 +33,20 @@ struct fwnode_endpoint {
const struct fwnode_handle *local_fwnode;
};
#define NR_FWNODE_REFERENCE_ARGS 8
/**
* struct fwnode_reference_args - Fwnode reference with additional arguments
* @fwnode:- A reference to the base fwnode
* @nargs: Number of elements in @args array
* @args: Integer arguments on the fwnode
*/
struct fwnode_reference_args {
struct fwnode_handle *fwnode;
unsigned int nargs;
unsigned int args[NR_FWNODE_REFERENCE_ARGS];
};
/**
* struct fwnode_operations - Operations for fwnode interface
* @get: Get a reference to an fwnode.
@@ -46,6 +60,7 @@ struct fwnode_endpoint {
* @get_parent: Return the parent of an fwnode.
* @get_next_child_node: Return the next child node in an iteration.
* @get_named_child_node: Return a child node with a given name.
* @get_reference_args: Return a reference pointed to by a property, with args
* @graph_get_next_endpoint: Return an endpoint node in an iteration.
* @graph_get_remote_endpoint: Return the remote endpoint node of a local
* endpoint node.
@@ -73,6 +88,10 @@ struct fwnode_operations {
struct fwnode_handle *
(*get_named_child_node)(const struct fwnode_handle *fwnode,
const char *name);
int (*get_reference_args)(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop,
unsigned int nargs, unsigned int index,
struct fwnode_reference_args *args);
struct fwnode_handle *
(*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
struct fwnode_handle *prev);