[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201019225903.14276-2-djrscally@gmail.com>
Date: Mon, 19 Oct 2020 23:58:55 +0100
From: Daniel Scally <djrscally@...il.com>
To: linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Cc: linux.walleij@...aro.org, prabhakar.mahadev-lad.rj@...renesas.com,
heikki.krogerus@...ux.intel.com, dmitry.torokhov@...il.com,
laurent.pinchart+renesas@...asonboard.com,
kieran.bingham+renesas@...asonboard.com, jacopo+renesas@...ndi.org,
robh@...nel.org, davem@...emloft.net, linux@...musvillemoes.dk,
andriy.shevchenko@...ux.intel.com, sergey.senozhatsky@...il.com,
rostedt@...dmis.org, pmladek@...e.com, mchehab@...nel.org,
tian.shu.qiu@...el.com, bingbu.cao@...el.com,
sakari.ailus@...ux.intel.com, yong.zhi@...el.com,
rafael@...nel.org, gregkh@...uxfoundation.org, kitakar@...il.com,
dan.carpenter@...cle.org
Subject: [RFC PATCH v3 1/9] software_node: Add helper function to unregister arrays of software_nodes ordered parent to child
Software nodes that are children of another software node should be
unregistered before their parent. To allow easy unregistering of an array
of software_nodes ordered parent to child, add a helper function to loop
over and unregister nodes in such an array in reverse order.
Suggested-by: Andriy Shevchenko <andriy.shevchenko@...ux.intel.com>
Signed-off-by: Daniel Scally <djrscally@...il.com>
---
Changes in v3:
- patch introduced.
drivers/base/swnode.c | 21 +++++++++++++++++++++
include/linux/property.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 010828fc7..f01b1cc61 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -727,6 +727,27 @@ void software_node_unregister_nodes(const struct software_node *nodes)
}
EXPORT_SYMBOL_GPL(software_node_unregister_nodes);
+/**
+ * software_node_unregister_nodes_reverse - Unregister an array of software
+ * nodes in reverse order.
+ * @nodes: Array of software nodes to be unregistered.
+ *
+ * NOTE: The same warning applies as with software_node_unregister_nodes.
+ * Unless you are _sure_ that the array of nodes is ordered parent to child
+ * it is wiser to remove them individually in the correct order.
+ */
+void software_node_unregister_nodes_reverse(const struct software_node *nodes)
+{
+ unsigned int i = 0;
+
+ while (nodes[i].name)
+ i++;
+
+ while (i--)
+ software_node_unregister(&nodes[i]);
+}
+EXPORT_SYMBOL_GPL(software_node_unregister_nodes_reverse);
+
/**
* software_node_register_node_group - Register a group of software nodes
* @node_group: NULL terminated array of software node pointers to be registered
diff --git a/include/linux/property.h b/include/linux/property.h
index 9f805c442..b6410258b 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -444,6 +444,7 @@ software_node_find_by_name(const struct software_node *parent,
int software_node_register_nodes(const struct software_node *nodes);
void software_node_unregister_nodes(const struct software_node *nodes);
+void software_node_unregister_nodes_reverse(const struct software_node *nodes);
int software_node_register_node_group(const struct software_node **node_group);
void software_node_unregister_node_group(const struct software_node **node_group);
--
2.17.1
Powered by blists - more mailing lists