public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-omap@vger.kernel.org
Cc: Dhruva Gole <d-gole@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [RFC PATCH 2/4] reset: Allow removing a lookup
Date: Thu, 11 Apr 2024 08:22:55 +0300	[thread overview]
Message-ID: <20240411052257.2113-3-tony@atomide.com> (raw)
In-Reply-To: <20240411052257.2113-1-tony@atomide.com>

If a parent device provides resets for the child devices using a lookup
table, let's also allow removal of the lookup table when removing the
child devices.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/reset/core.c             | 27 +++++++++++++++++++++++++++
 include/linux/reset-controller.h |  7 +++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -217,6 +217,33 @@ void reset_controller_add_lookup(struct reset_control_lookup *lookup,
 }
 EXPORT_SYMBOL_GPL(reset_controller_add_lookup);
 
+/**
+ * reset_controller_remove_lookup - unregister a set of lookup entries
+ * @lookup: array of reset lookup entries
+ * @num_entries: number of entries in the lookup array
+ */
+void reset_controller_remove_lookup(struct reset_control_lookup *lookup,
+				    unsigned int num_entries)
+{
+	struct reset_control_lookup *entry;
+	unsigned int i;
+
+	mutex_lock(&reset_lookup_mutex);
+	for (i = 0; i < num_entries; i++) {
+		entry = &lookup[i];
+
+		if (!entry->dev_id || !entry->provider) {
+			pr_warn("%s(): reset lookup entry badly specified, skipping\n",
+				__func__);
+			continue;
+		}
+
+		list_del(&entry->list);
+	}
+	mutex_unlock(&reset_lookup_mutex);
+}
+EXPORT_SYMBOL_GPL(reset_controller_remove_lookup);
+
 static inline struct reset_control_array *
 rstc_to_array(struct reset_control *rstc) {
 	return container_of(rstc, struct reset_control_array, base);
diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h
--- a/include/linux/reset-controller.h
+++ b/include/linux/reset-controller.h
@@ -93,6 +93,8 @@ int devm_reset_controller_register(struct device *dev,
 
 void reset_controller_add_lookup(struct reset_control_lookup *lookup,
 				 unsigned int num_entries);
+void reset_controller_remove_lookup(struct reset_control_lookup *lookup,
+				    unsigned int num_entries);
 #else
 static inline int reset_controller_register(struct reset_controller_dev *rcdev)
 {
@@ -113,6 +115,11 @@ static inline void reset_controller_add_lookup(struct reset_control_lookup *look
 					       unsigned int num_entries)
 {
 }
+
+static inline void reset_controller_remove_lookup(struct reset_control_lookup *lookup,
+						  unsigned int num_entries)
+{
+}
 #endif
 
 #endif
-- 
2.44.0

  parent reply	other threads:[~2024-04-11  5:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  5:22 [RFC PATCH 0/4] Provide interconnect resets for ti-sysc users Tony Lindgren
2024-04-11  5:22 ` [RFC PATCH 1/4] reset: Fall back to lookup if no reset node is found Tony Lindgren
2024-04-11  5:22 ` Tony Lindgren [this message]
2024-04-11  5:22 ` [RFC PATCH 3/4] bus: ti-sysc: Implement reset control framework for soft reset Tony Lindgren
2024-04-11  5:22 ` [RFC PATCH 4/4] serial: 8250: omap: Use reset control for resets Tony Lindgren

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=20240411052257.2113-3-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=d-gole@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    /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