mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
devres: add devres_node_remove()
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. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://patch.msgid.link/20260213220718.82835-4-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
9738ca7df9
commit
b1081ef74d
|
|
@ -231,6 +231,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 *),
|
||||
|
|
|
|||
|
|
@ -365,6 +365,22 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* devres_remove - Find a device resource and remove it
|
||||
* @dev: Device to find resource from
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user