diff mbox

[2/4] backports: add backport for idr_remove

Message ID 1489064253-3652-3-git-send-email-arend.vanspriel@broadcom.com (mailing list archive)
State Accepted
Headers show

Commit Message

Arend van Spriel March 9, 2017, 12:57 p.m. UTC
Since commit d3e709e63e97 ("idr: Return the deleted entry from
idr_remove") the function signature changed so provide a backport
which does a idr_find() and subsequent idr_remove().

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
Hi Johannes,

Not sure if the find/remove approach is a good one here. Better solutions
are welcome.

Regards,
Arend
---
 backport/backport-include/linux/idr.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox

Patch

diff --git a/backport/backport-include/linux/idr.h b/backport/backport-include/linux/idr.h
index d7cf9f0..01aa2c2 100644
--- a/backport/backport-include/linux/idr.h
+++ b/backport/backport-include/linux/idr.h
@@ -61,4 +61,14 @@  static inline void idr_preload_end(void)
 	for (id = 0; ((entry) = idr_get_next(idp, &(id))) != NULL; ++id)
 #endif

+#if LINUX_VERSION_IS_LESS(4, 11, 0)
+static inline void *backport_idr_remove(struct idr *idr, int id)
+{
+	void *item = idr_find(idr, id);
+	idr_remove(idr, id);
+	return item;
+}
+#define idr_remove	backport_idr_remove
+#endif
+
 #endif /* __BACKPORT_IDR_H */