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 Teach idr_remove to accept failure.
details: https://anonhg.NetBSD.org/src/rev/a86d6e0d0094
branches: trunk
changeset: 1027910:a86d6e0d0094
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 01:15:21 2021 +0000
description:
Teach idr_remove to accept failure.
But teach it to return the data if it succeeds too.
diffstat:
sys/external/bsd/drm2/include/linux/idr.h | 4 ++--
sys/external/bsd/drm2/linux/linux_idr.c | 19 +++++++++++++------
2 files changed, 15 insertions(+), 8 deletions(-)
diffs (67 lines):
diff -r 38b359d40cb7 -r a86d6e0d0094 sys/external/bsd/drm2/include/linux/idr.h
--- a/sys/external/bsd/drm2/include/linux/idr.h Sun Dec 19 01:15:14 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/idr.h Sun Dec 19 01:15:21 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: idr.h,v 1.8 2021/12/19 01:00:17 riastradh Exp $ */
+/* $NetBSD: idr.h,v 1.9 2021/12/19 01:15:21 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
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_remove(struct idr *, int);
void idr_preload(gfp_t);
int idr_alloc(struct idr *, void *, int, int, gfp_t);
void idr_preload_end(void);
diff -r 38b359d40cb7 -r a86d6e0d0094 sys/external/bsd/drm2/linux/linux_idr.c
--- a/sys/external/bsd/drm2/linux/linux_idr.c Sun Dec 19 01:15:14 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_idr.c Sun Dec 19 01:15:21 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_idr.c,v 1.13 2021/12/19 01:00:17 riastradh Exp $ */
+/* $NetBSD: linux_idr.c,v 1.14 2021/12/19 01:15:21 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.13 2021/12/19 01:00:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.14 2021/12/19 01:15:21 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -259,19 +259,26 @@
return result;
}
-void
+void *
idr_remove(struct idr *idr, int id)
{
struct idr_node *node;
+ void *data;
mutex_spin_enter(&idr->idr_lock);
node = rb_tree_find_node(&idr->idr_tree, &id);
- KASSERTMSG((node != NULL), "idr %p has no entry for id %d", idr, id);
- SDT_PROBE3(sdt, linux, idr, remove, idr, id, node->in_data);
- rb_tree_remove_node(&idr->idr_tree, node);
+ if (node == NULL) {
+ data = NULL;
+ } else {
+ data = node->in_data;
+ SDT_PROBE3(sdt, linux, idr, remove, idr, id, data);
+ rb_tree_remove_node(&idr->idr_tree, node);
+ }
mutex_spin_exit(&idr->idr_lock);
kmem_free(node, sizeof(*node));
+
+ return data;
}
void
Home |
Main Index |
Thread Index |
Old Index