Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Apr 2026 18:10:30 +0000
From:      Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: cff716c2854c - main - linuxkpi: Add `rb_add()`
Message-ID:  <69e90f16.43579.360711f8@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by dumbbell:

URL: https://cgit.FreeBSD.org/src/commit/?id=cff716c2854c167ef7ff3a4785f5faed9b0a4f98

commit cff716c2854c167ef7ff3a4785f5faed9b0a4f98
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-21 00:38:56 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-22 18:09:56 +0000

    linuxkpi: Add `rb_add()`
    
    It is the same as `rb_add_cached()` but it works on `struct rb_root`, not
    a `struc rb_root_cached`. It also does not return anything.
    
    The DRM generic code started to use this in Linux 6.12.x.
    
    Reviewed by:    bz
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D56577
---
 sys/compat/linuxkpi/common/include/linux/rbtree.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/rbtree.h b/sys/compat/linuxkpi/common/include/linux/rbtree.h
index e6033cfd760d..834e5645e991 100644
--- a/sys/compat/linuxkpi/common/include/linux/rbtree.h
+++ b/sys/compat/linuxkpi/common/include/linux/rbtree.h
@@ -199,6 +199,26 @@ rb_add_cached(struct rb_node *node, struct rb_root_cached *tree,
 	return (leftmost ? node : NULL);
 }
 
+static inline void
+rb_add(struct rb_node *node, struct rb_root *tree,
+    bool (*less)(struct rb_node *, const struct rb_node *))
+{
+	struct rb_node **link = &tree->rb_node;
+	struct rb_node *parent = NULL;
+
+	while (*link != NULL) {
+		parent = *link;
+		if (less(node, parent)) {
+			link = &RB_LEFT(parent, __entry);
+		} else {
+			link = &RB_RIGHT(parent, __entry);
+		}
+	}
+
+	rb_link_node(node, parent, link);
+	rb_insert_color(node, tree);
+}
+
 #undef RB_ROOT
 #define RB_ROOT		(struct rb_root) { NULL }
 #define	RB_ROOT_CACHED	(struct rb_root_cached) { RB_ROOT, NULL }


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e90f16.43579.360711f8>