diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2016-12-22 21:30:22 +0300 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2017-02-14 05:44:03 +0300 |
commit | d3e709e63e97e5f3f129b639991cfe266da60bae (patch) | |
tree | 78647f4029b9e83087fefa19144a689f6909f8d2 /include/linux | |
parent | 8ac04868315c6ffcb2c5a5ad9cd5cec61cad3576 (diff) | |
download | linux-d3e709e63e97e5f3f129b639991cfe266da60bae.tar.xz |
idr: Return the deleted entry from idr_remove
It is a relatively common idiom (8 instances) to first look up an IDR
entry, and then remove it from the tree if it is found, possibly doing
further operations upon the entry afterwards. If we change idr_remove()
to return the removed object, all of these users can save themselves a
walk of the IDR tree.
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/idr.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index 2027c7aba50d..bf70b3ef0a07 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -88,9 +88,9 @@ void *idr_get_next(struct idr *, int *nextid); void *idr_replace(struct idr *, void *, int id); void idr_destroy(struct idr *); -static inline void idr_remove(struct idr *idr, int id) +static inline void *idr_remove(struct idr *idr, int id) { - radix_tree_delete(&idr->idr_rt, id); + return radix_tree_delete_item(&idr->idr_rt, id, NULL); } static inline void idr_init(struct idr *idr) |