Skip to content

Commit

Permalink
interconnect: Add a common helper for removing all nodes
Browse files Browse the repository at this point in the history
The removal of all nodes from a provider seem to be a common functionality
for all existing users and it would make sense to factor out this into a
a common helper function.

Suggested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
  • Loading branch information
Georgi Djakov committed Dec 16, 2019
1 parent d1eef1c commit 3cce2c6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/interconnect/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,28 @@ void icc_node_del(struct icc_node *node)
}
EXPORT_SYMBOL_GPL(icc_node_del);

/**
* icc_nodes_remove() - remove all previously added nodes from provider
* @provider: the interconnect provider we are removing nodes from
*
* Return: 0 on success, or an error code otherwise
*/
int icc_nodes_remove(struct icc_provider *provider)
{
struct icc_node *n, *tmp;

if (WARN_ON(IS_ERR_OR_NULL(provider)))
return -EINVAL;

list_for_each_entry_safe_reverse(n, tmp, &provider->nodes, node_list) {
icc_node_del(n);
icc_node_destroy(n->id);
}

return 0;
}
EXPORT_SYMBOL_GPL(icc_nodes_remove);

/**
* icc_provider_add() - add a new interconnect provider
* @provider: the interconnect provider that will be added into topology
Expand Down
6 changes: 6 additions & 0 deletions include/linux/interconnect-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ int icc_link_create(struct icc_node *node, const int dst_id);
int icc_link_destroy(struct icc_node *src, struct icc_node *dst);
void icc_node_add(struct icc_node *node, struct icc_provider *provider);
void icc_node_del(struct icc_node *node);
int icc_nodes_remove(struct icc_provider *provider);
int icc_provider_add(struct icc_provider *provider);
int icc_provider_del(struct icc_provider *provider);

Expand Down Expand Up @@ -130,6 +131,11 @@ void icc_node_del(struct icc_node *node)
{
}

static inline int icc_nodes_remove(struct icc_provider *provider)
{
return -ENOTSUPP;
}

static inline int icc_provider_add(struct icc_provider *provider)
{
return -ENOTSUPP;
Expand Down

0 comments on commit 3cce2c6

Please sign in to comment.