summaryrefslogtreecommitdiff
path: root/drivers/interconnect
diff options
context:
space:
mode:
authorGeorgi Djakov <georgi.djakov@linaro.org>2019-12-02 19:21:32 +0300
committerGeorgi Djakov <georgi.djakov@linaro.org>2019-12-16 10:25:22 +0300
commit3cce2c6fa70c768e516bff011d77db72e2f38a15 (patch)
tree654af863e34de771a9e5b2532145f9a3a8e6af98 /drivers/interconnect
parentd1eef1c619749b2a57e514a3fa67d9a516ffa919 (diff)
downloadlinux-3cce2c6fa70c768e516bff011d77db72e2f38a15.tar.xz
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 <digetx@gmail.com> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Diffstat (limited to 'drivers/interconnect')
-rw-r--r--drivers/interconnect/core.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index c498796adc07..1b811423020a 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -743,6 +743,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
*