Skip to content

Commit c2c724c

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: Add fw_devlink_parse_fwtree()
This function is a wrapper around fwnode_operations.add_links(). This function parses each node in a fwnode tree and create fwnode links for each of those nodes. The information for creating the fwnode links (the supplier and consumer fwnode) is obtained by parsing the properties in each of the fwnodes. This function also ensures that no fwnode is parsed more than once by marking the fwnodes as parsed. Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20201121020232.908850-13-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 04f63c2 commit c2c724c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/base/core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,25 @@ static bool fw_devlink_is_permissive(void)
15421542
return fw_devlink_flags == DL_FLAG_SYNC_STATE_ONLY;
15431543
}
15441544

1545+
static void fw_devlink_parse_fwnode(struct fwnode_handle *fwnode)
1546+
{
1547+
if (fwnode->flags & FWNODE_FLAG_LINKS_ADDED)
1548+
return;
1549+
1550+
fwnode_call_int_op(fwnode, add_links, NULL);
1551+
fwnode->flags |= FWNODE_FLAG_LINKS_ADDED;
1552+
}
1553+
1554+
static void fw_devlink_parse_fwtree(struct fwnode_handle *fwnode)
1555+
{
1556+
struct fwnode_handle *child = NULL;
1557+
1558+
fw_devlink_parse_fwnode(fwnode);
1559+
1560+
while ((child = fwnode_get_next_available_child_node(fwnode, child)))
1561+
fw_devlink_parse_fwtree(child);
1562+
}
1563+
15451564
static void fw_devlink_link_device(struct device *dev)
15461565
{
15471566
int fw_ret;

include/linux/fwnode.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
struct fwnode_operations;
1616
struct device;
1717

18+
/*
19+
* fwnode link flags
20+
*
21+
* LINKS_ADDED: The fwnode has already be parsed to add fwnode links.
22+
*/
23+
#define FWNODE_FLAG_LINKS_ADDED BIT(0)
24+
1825
struct fwnode_handle {
1926
struct fwnode_handle *secondary;
2027
const struct fwnode_operations *ops;
2128
struct device *dev;
2229
struct list_head suppliers;
2330
struct list_head consumers;
31+
u8 flags;
2432
};
2533

2634
struct fwnode_link {

0 commit comments

Comments
 (0)