fwnode property API improvements
Subsystems (4)
Sakari Ailus
reviewercover fwnode property API improvements
Hi,
This patchset does two things: make fwnode_handle_get() return the node, just as of_node_get() does, and add a macro for iterating over graph endpoints. The V4L2 fwnode framework would be a user for the macro.
Sakari Ailus (2):
device property: Make fwnode_handle_get() return the fwnode device property: Add a macro for interating over graph endpoints
drivers/base/property.c | 9 +++++++-- drivers/of/property.c | 4 ++-- include/linux/fwnode.h | 2 +- include/linux/property.h | 6 +++++- 4 files changed, 15 insertions(+), 6 deletions(-)
Signature · 1 line
2.11.0
Sakari Ailus
reviewerPATCH 1/2 device property: Make fwnode_handle_get() return the fwnode
The fwnode_handle_get() function is used to obtain a reference to an fwnode. A common usage pattern for the OF equivalent of the function is:
mynode = of_node_get(node);
Similarly make fwnode_handle_get() return the fwnode to which the reference was obtained.
--- drivers/base/property.c | 9 +++++++-- drivers/of/property.c | 4 ++-- include/linux/fwnode.h | 2 +- include/linux/property.h | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-)
drivers/base/property.c +7 -2
@@ -1037,10 +1037,15 @@ EXPORT_SYMBOL_GPL(device_get_named_child_node);/** * fwnode_handle_get - Obtain a reference to a device node * @fwnode: Pointer to the device node to obtain the reference to. +* +* Returns the fwnode handle. */ -void fwnode_handle_get (struct fwnode_handle *fwnode) +struct fwnode_handle *fwnode_handle_get (struct fwnode_handle *fwnode) { -fwnode_call_void_op (fwnode, get); +if (!fwnode_has_op (fwnode, get)) +return fwnode; + +return fwnode_call_ptr_op (fwnode, get); }EXPORT_SYMBOL_GPL (fwnode_handle_get);
drivers/of/property.c +2 -2
@@ -817,9 +817,9 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, }EXPORT_SYMBOL (of_graph_get_remote_node); -static void of_fwnode_get (struct fwnode_handle *fwnode) +static struct fwnode_handle *of_fwnode_get (struct fwnode_handle *fwnode) { -of_node_get (to_of_node (fwnode)); +return of_fwnode_handle (of_node_get (to_of_node (fwnode))); }static void of_fwnode_put (struct fwnode_handle *fwnode)
include/linux/fwnode.h +1 -1
@@ -68,7 +68,7 @@ struct fwnode_reference_args {* @graph_parse_endpoint: Parse endpoint for port and endpoint id. */ struct fwnode_operations { -void (*get)(struct fwnode_handle *fwnode); +struct fwnode_handle *(*get)(struct fwnode_handle *fwnode);void (*put)(struct fwnode_handle *fwnode);bool (*device_is_available)(const struct fwnode_handle *fwnode); bool (*property_present)(const struct fwnode_handle *fwnode,
include/linux/property.h +1 -1
@@ -100,7 +100,7 @@ struct fwnode_handle *fwnode_get_named_child_node(struct fwnode_handle *device_get_named_child_node (struct device *dev,const char *childname); -void fwnode_handle_get (struct fwnode_handle *fwnode); +struct fwnode_handle *fwnode_handle_get (struct fwnode_handle *fwnode);void fwnode_handle_put (struct fwnode_handle *fwnode);unsigned int device_get_child_node_count (struct device *dev);
Signature · 1 line
2.11.0
Sakari Ailus
reviewerPATCH 2/2 device property: Add a macro for interating over graph endpoints
In reply to Sakari AilusAdd a convenience macro for iterating over graph endpoints. Iterating over graph endpoints using fwnode_graph_get_next_endpoint() is a recurring pattern, and this macro allows calling that function in a slightly more convenient way. For instance,
for (child = NULL; (child = fwnode_graph_get_next_endpoint(fwnode, child)); )
becomes
fwnode_graph_for_each_endpoint(fwnode, child)
--- include/linux/property.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/property.h +4 -0
@@ -293,6 +293,10 @@ struct fwnode_handle * fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port, u32 endpoint); +#define fwnode_graph_for_each_endpoint (fwnode, child) \ + for (child = NULL; \ + (child = fwnode_graph_get_next_endpoint(fwnode, child)); ) +int fwnode_graph_parse_endpoint (const struct fwnode_handle *fwnode,struct fwnode_endpoint *endpoint);
Signature · 1 line
2.11.0