From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org, ojeda@kernel.org,
boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
tmgross@umich.edu
Cc: driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH 3/5] devres: add devres_node_remove()
Date: Thu, 5 Feb 2026 23:31:26 +0100 [thread overview]
Message-ID: <20260205224706.91996-5-dakr@kernel.org> (raw)
In-Reply-To: <20260205224706.91996-2-dakr@kernel.org>
When the Rust Devres<T> container type is dropped we need a way to
remove the embedded struct devres_node from the device's node list.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
drivers/base/base.h | 1 +
drivers/base/devres.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 0ad52a847bd0..93b2020baa99 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -237,6 +237,7 @@ struct devres_node {
void devres_node_init(struct devres_node *node, dr_node_release_t release,
dr_node_free_t free_node);
void devres_node_add(struct device *dev, struct devres_node *node);
+bool devres_node_remove(struct device *dev, struct devres_node *node);
void devres_for_each_res(struct device *dev, dr_release_t release,
dr_match_t match, void *match_data,
void (*fn)(struct device *, void *, void *),
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 51d079acc9b3..54a41ae599d0 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -363,6 +363,23 @@ void *devres_get(struct device *dev, void *new_res,
}
EXPORT_SYMBOL_GPL(devres_get);
+bool devres_node_remove(struct device *dev, struct devres_node *node)
+{
+ struct devres_node *__node;
+
+ guard(spinlock_irqsave)(&dev->devres_lock);
+ list_for_each_entry_reverse(__node, &dev->devres_head, entry) {
+ if (__node == node) {
+ list_del_init(&node->entry);
+ devres_log(dev, node, "REM");
+ return true;
+ }
+ }
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(devres_node_remove);
+
/**
* devres_remove - Find a device resource and remove it
* @dev: Device to find resource from
--
2.52.0
next prev parent reply other threads:[~2026-02-05 22:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 22:31 [PATCH 0/5] Use struct devres_node in Devres<T> Danilo Krummrich
2026-02-05 22:31 ` [PATCH 1/5] devres: move struct devres_node into base.h Danilo Krummrich
2026-02-05 22:31 ` [PATCH 2/5] devres: export devres_node_init() and devres_node_add() Danilo Krummrich
2026-02-06 10:43 ` Danilo Krummrich
2026-02-06 11:04 ` Greg KH
2026-02-06 11:32 ` Danilo Krummrich
2026-02-06 11:34 ` Alice Ryhl
2026-02-06 11:46 ` Danilo Krummrich
2026-02-06 12:34 ` Greg KH
2026-02-06 13:16 ` Danilo Krummrich
2026-02-06 13:20 ` Alice Ryhl
2026-02-06 13:25 ` Greg KH
2026-02-06 13:33 ` Danilo Krummrich
2026-02-06 13:35 ` Alice Ryhl
2026-02-06 13:22 ` Greg KH
2026-02-06 13:33 ` Alice Ryhl
2026-02-06 13:55 ` Greg KH
2026-02-06 14:23 ` Gary Guo
2026-02-06 14:31 ` Greg KH
2026-02-06 15:09 ` Alice Ryhl
2026-02-06 16:31 ` Alice Ryhl
2026-02-06 14:08 ` Danilo Krummrich
2026-02-05 22:31 ` Danilo Krummrich [this message]
2026-02-05 22:31 ` [PATCH 4/5] devres: rename and export set_node_dbginfo() Danilo Krummrich
2026-02-05 22:31 ` [PATCH 5/5] rust: devres: embed struct devres_node directly Danilo Krummrich
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=20260205224706.91996-5-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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