Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2 Implement idr_replace.
details: https://anonhg.NetBSD.org/src/rev/53f2f8891f0c
branches: riastradh-drm2
changeset: 788078:53f2f8891f0c
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 02:07:46 2013 +0000
description:
Implement idr_replace.
diffstat:
sys/external/bsd/drm2/include/linux/idr.h | 3 ++-
sys/external/bsd/drm2/linux/linux_idr.c | 24 ++++++++++++++++++++++--
2 files changed, 24 insertions(+), 3 deletions(-)
diffs (68 lines):
diff -r 329c2e7d39d1 -r 53f2f8891f0c sys/external/bsd/drm2/include/linux/idr.h
--- a/sys/external/bsd/drm2/include/linux/idr.h Wed Jul 24 02:07:31 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/idr.h Wed Jul 24 02:07:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: idr.h,v 1.1.2.3 2013/07/24 02:07:09 riastradh Exp $ */
+/* $NetBSD: idr.h,v 1.1.2.4 2013/07/24 02:07:46 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,6 +47,7 @@
void idr_init(struct idr *);
void idr_destroy(struct idr *);
void *idr_find(struct idr *, int);
+void *idr_replace(struct idr *, void *, int);
void idr_remove(struct idr *, int);
void idr_remove_all(struct idr *);
int idr_pre_get(struct idr *, int);
diff -r 329c2e7d39d1 -r 53f2f8891f0c sys/external/bsd/drm2/linux/linux_idr.c
--- a/sys/external/bsd/drm2/linux/linux_idr.c Wed Jul 24 02:07:31 2013 +0000
+++ b/sys/external/bsd/drm2/linux/linux_idr.c Wed Jul 24 02:07:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_idr.c,v 1.1.2.3 2013/07/24 02:07:09 riastradh Exp $ */
+/* $NetBSD: linux_idr.c,v 1.1.2.4 2013/07/24 02:07:46 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.1.2.3 2013/07/24 02:07:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.1.2.4 2013/07/24 02:07:46 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
#include <sys/kmem.h>
#include <sys/rbtree.h>
+#include <linux/err.h>
#include <linux/idr.h>
struct idr_node {
@@ -121,6 +122,25 @@
return data;
}
+void *
+idr_replace(struct idr *idr, void *replacement, int id)
+{
+ struct idr_node *node;
+ void *result;
+
+ rw_enter(&idr->idr_lock, RW_WRITER);
+ node = rb_tree_find_node(&idr->idr_tree, &id);
+ if (node == NULL) {
+ result = ERR_PTR(-ENOENT);
+ } else {
+ result = node->in_data;
+ node->in_data = replacement;
+ }
+ rw_exit(&idr->idr_lock);
+
+ return result;
+}
+
void
idr_remove(struct idr *idr, int id)
{
Home |
Main Index |
Thread Index |
Old Index