Skip to content

Commit 3cce2c6

Browse files
author
Georgi Djakov
committed
interconnect: Add a common helper for removing all nodes
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 <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Georgi Djakov <[email protected]>
1 parent d1eef1c commit 3cce2c6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

drivers/interconnect/core.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,28 @@ void icc_node_del(struct icc_node *node)
742742
}
743743
EXPORT_SYMBOL_GPL(icc_node_del);
744744

745+
/**
746+
* icc_nodes_remove() - remove all previously added nodes from provider
747+
* @provider: the interconnect provider we are removing nodes from
748+
*
749+
* Return: 0 on success, or an error code otherwise
750+
*/
751+
int icc_nodes_remove(struct icc_provider *provider)
752+
{
753+
struct icc_node *n, *tmp;
754+
755+
if (WARN_ON(IS_ERR_OR_NULL(provider)))
756+
return -EINVAL;
757+
758+
list_for_each_entry_safe_reverse(n, tmp, &provider->nodes, node_list) {
759+
icc_node_del(n);
760+
icc_node_destroy(n->id);
761+
}
762+
763+
return 0;
764+
}
765+
EXPORT_SYMBOL_GPL(icc_nodes_remove);
766+
745767
/**
746768
* icc_provider_add() - add a new interconnect provider
747769
* @provider: the interconnect provider that will be added into topology

include/linux/interconnect-provider.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ int icc_link_create(struct icc_node *node, const int dst_id);
9898
int icc_link_destroy(struct icc_node *src, struct icc_node *dst);
9999
void icc_node_add(struct icc_node *node, struct icc_provider *provider);
100100
void icc_node_del(struct icc_node *node);
101+
int icc_nodes_remove(struct icc_provider *provider);
101102
int icc_provider_add(struct icc_provider *provider);
102103
int icc_provider_del(struct icc_provider *provider);
103104

@@ -130,6 +131,11 @@ void icc_node_del(struct icc_node *node)
130131
{
131132
}
132133

134+
static inline int icc_nodes_remove(struct icc_provider *provider)
135+
{
136+
return -ENOTSUPP;
137+
}
138+
133139
static inline int icc_provider_add(struct icc_provider *provider)
134140
{
135141
return -ENOTSUPP;

0 commit comments

Comments
 (0)