From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-acpi@vger.kernel.org,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/6] software node: Allow register and unregister software node groups
Date: Wed, 8 Apr 2020 19:09:02 +0300 [thread overview]
Message-ID: <20200408160905.12101-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200408160905.12101-1-andriy.shevchenko@linux.intel.com>
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>
---
drivers/base/swnode.c | 48 ++++++++++++++++++++++++++++++++++++++++
include/linux/property.h | 3 +++
2 files changed, 51 insertions(+)
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index de8d3543e8fe..2079937ddb51 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -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
diff --git a/include/linux/property.h b/include/linux/property.h
index d86de017c689..c7b5f3db36aa 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -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);
--
2.25.1
next prev parent reply other threads:[~2020-04-08 16:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 16:09 [PATCH v1 0/6] platform/x86: intel_cht_int33fe: clean up series Andy Shevchenko
2020-04-08 16:09 ` [PATCH v1 1/6] device property: export set_secondary_fwnode() to modules Andy Shevchenko
2020-04-08 16:09 ` Andy Shevchenko [this message]
2020-04-08 16:09 ` [PATCH v1 3/6] platform/x86: intel_cht_int33fe: Convert software node array to group Andy Shevchenko
2020-04-08 16:09 ` [PATCH v1 4/6] platform/x86: intel_cht_int33fe: Convert to use set_secondary_fwnode() Andy Shevchenko
2020-04-08 16:09 ` [PATCH v1 5/6] platform/x86: intel_cht_int33fe: Switch to use acpi_dev_hid_uid_match() Andy Shevchenko
2020-04-08 16:09 ` [PATCH v1 6/6] platform/x86: intel_cht_int33fe: Fix spelling issues Andy Shevchenko
2020-04-14 12:08 ` [PATCH v1 0/6] platform/x86: intel_cht_int33fe: clean up series Hans de Goede
2020-04-14 12:31 ` Andy Shevchenko
2020-04-14 12:17 ` Heikki Krogerus
2020-04-16 14:17 ` Andy Shevchenko
2020-04-16 15:03 ` Rafael J. Wysocki
2020-04-16 15:21 ` Andy Shevchenko
2020-04-18 19:43 ` Rafael J. Wysocki
2020-04-19 8:50 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200408160905.12101-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dvhart@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).