Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux Add idr_get_next and idr_for_eac...
details: https://anonhg.NetBSD.org/src/rev/398b2fbc59ec
branches: trunk
changeset: 992532:398b2fbc59ec
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 27 06:55:01 2018 +0000
description:
Add idr_get_next and idr_for_each_entry.
diffstat:
sys/external/bsd/drm2/include/linux/idr.h | 7 ++++++-
sys/external/bsd/drm2/linux/linux_idr.c | 23 +++++++++++++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diffs (79 lines):
diff -r 2fa814b5d0cd -r 398b2fbc59ec sys/external/bsd/drm2/include/linux/idr.h
--- a/sys/external/bsd/drm2/include/linux/idr.h Mon Aug 27 06:54:51 2018 +0000
+++ b/sys/external/bsd/drm2/include/linux/idr.h Mon Aug 27 06:55:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: idr.h,v 1.4 2018/08/27 06:54:51 riastradh Exp $ */
+/* $NetBSD: idr.h,v 1.5 2018/08/27 06:55:01 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -51,6 +51,7 @@
#define idr_destroy linux_idr_destroy
#define idr_find linux_idr_find
#define idr_for_each linux_idr_for_each
+#define idr_get_next linux_idr_get_next
#define idr_init linux_idr_init
#define idr_is_empty linux_idr_is_empty
#define idr_preload linux_idr_preload
@@ -65,6 +66,7 @@
void idr_destroy(struct idr *);
bool idr_is_empty(struct idr *);
void *idr_find(struct idr *, int);
+void *idr_get_next(struct idr *, int *);
void *idr_replace(struct idr *, void *, int);
void idr_remove(struct idr *, int);
void idr_preload(gfp_t);
@@ -72,6 +74,9 @@
void idr_preload_end(void);
int idr_for_each(struct idr *, int (*)(int, void *, void *), void *);
+#define idr_for_each_entry(IDR, ENTRY, ID) \
+ for ((ID) = 0; ((ENTRY) = idr_get_next((IDR), &(ID))) != NULL; (ID)++)
+
struct ida {
struct idr ida_idr;
};
diff -r 2fa814b5d0cd -r 398b2fbc59ec sys/external/bsd/drm2/linux/linux_idr.c
--- a/sys/external/bsd/drm2/linux/linux_idr.c Mon Aug 27 06:54:51 2018 +0000
+++ b/sys/external/bsd/drm2/linux/linux_idr.c Mon Aug 27 06:55:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_idr.c,v 1.6 2017/07/26 03:40:39 riastradh Exp $ */
+/* $NetBSD: linux_idr.c,v 1.7 2018/08/27 06:55:01 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.6 2017/07/26 03:40:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.7 2018/08/27 06:55:01 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -151,6 +151,25 @@
}
void *
+idr_get_next(struct idr *idr, int *idp)
+{
+ const struct idr_node *node;
+ void *data;
+
+ mutex_spin_enter(&idr->idr_lock);
+ node = rb_tree_find_node_geq(&idr->idr_tree, idp);
+ if (node == NULL) {
+ data = NULL;
+ } else {
+ data = node->in_data;
+ *idp = node->in_index;
+ }
+ mutex_spin_exit(&idr->idr_lock);
+
+ return data;
+}
+
+void *
idr_replace(struct idr *idr, void *replacement, int id)
{
struct idr_node *node;
Home |
Main Index |
Thread Index |
Old Index