]> git.baikalelectronics.ru Git - kernel.git/commitdiff
software node: Allow register and unregister software node groups
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 8 Apr 2020 16:09:02 +0000 (19:09 +0300)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 20 Apr 2020 11:41:56 +0000 (14:41 +0300)
Sometimes it's more convenient to register a set of individual software nodes
grouped together. Add couple of functions for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
drivers/base/swnode.c
include/linux/property.h

index de8d3543e8fe347be2ffc2f3afdedd4ef84fd35c..2079937ddb51c19367be841481f895da181759ac 100644 (file)
@@ -726,6 +726,54 @@ void software_node_unregister_nodes(const struct software_node *nodes)
 }
 EXPORT_SYMBOL_GPL(software_node_unregister_nodes);
 
+/**
+ * software_node_register_node_group - Register a group of software nodes
+ * @node_group: NULL terminated array of software node pointers to be registered
+ *
+ * Register multiple software nodes at once.
+ */
+int software_node_register_node_group(const struct software_node **node_group)
+{
+       unsigned int i;
+       int ret;
+
+       if (!node_group)
+               return 0;
+
+       for (i = 0; node_group[i]; i++) {
+               ret = software_node_register(node_group[i]);
+               if (ret) {
+                       software_node_unregister_node_group(node_group);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(software_node_register_node_group);
+
+/**
+ * software_node_unregister_node_group - Unregister a group of software nodes
+ * @node_group: NULL terminated array of software node pointers to be unregistered
+ *
+ * Unregister multiple software nodes at once.
+ */
+void software_node_unregister_node_group(const struct software_node **node_group)
+{
+       struct swnode *swnode;
+       unsigned int i;
+
+       if (!node_group)
+               return;
+
+       for (i = 0; node_group[i]; i++) {
+               swnode = software_node_to_swnode(node_group[i]);
+               if (swnode)
+                       fwnode_remove_software_node(&swnode->fwnode);
+       }
+}
+EXPORT_SYMBOL_GPL(software_node_unregister_node_group);
+
 /**
  * software_node_register - Register static software node
  * @node: The software node to be registered
index d86de017c689c1278044a454d46e077e7aadccc6..c7b5f3db36aa810925ad15112a1a4e129404e318 100644 (file)
@@ -440,6 +440,9 @@ 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);
 
+int software_node_register_node_group(const struct software_node **node_group);
+void software_node_unregister_node_group(const struct software_node **node_group);
+
 int software_node_register(const struct software_node *node);
 
 int software_node_notify(struct device *dev, unsigned long action);