Skip to content

Commit

Permalink
driver core: Add fw_devlink_parse_fwtree()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Saravana Kannan authored and Greg Kroah-Hartman committed Dec 9, 2020
1 parent 04f63c2 commit c2c724c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,25 @@ static bool fw_devlink_is_permissive(void)
return fw_devlink_flags == DL_FLAG_SYNC_STATE_ONLY;
}

static void fw_devlink_parse_fwnode(struct fwnode_handle *fwnode)
{
if (fwnode->flags & FWNODE_FLAG_LINKS_ADDED)
return;

fwnode_call_int_op(fwnode, add_links, NULL);
fwnode->flags |= FWNODE_FLAG_LINKS_ADDED;
}

static void fw_devlink_parse_fwtree(struct fwnode_handle *fwnode)
{
struct fwnode_handle *child = NULL;

fw_devlink_parse_fwnode(fwnode);

while ((child = fwnode_get_next_available_child_node(fwnode, child)))
fw_devlink_parse_fwtree(child);
}

static void fw_devlink_link_device(struct device *dev)
{
int fw_ret;
Expand Down
8 changes: 8 additions & 0 deletions include/linux/fwnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@
struct fwnode_operations;
struct device;

/*
* fwnode link flags
*
* LINKS_ADDED: The fwnode has already be parsed to add fwnode links.
*/
#define FWNODE_FLAG_LINKS_ADDED BIT(0)

struct fwnode_handle {
struct fwnode_handle *secondary;
const struct fwnode_operations *ops;
struct device *dev;
struct list_head suppliers;
struct list_head consumers;
u8 flags;
};

struct fwnode_link {
Expand Down

0 comments on commit c2c724c

Please sign in to comment.