Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Apr 2026 21:43:06 +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-branches@FreeBSD.org
Subject:   git: b34aa6b52d88 - stable/15 - linuxkpi: Add `rb_add()`
Message-ID:  <69f27b6a.18d0b.442cf296@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by dumbbell:

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

commit b34aa6b52d88f56605df8825e1be5b8c634f78dd
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-29 21:04:07 +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
    
    (cherry picked from commit cff716c2854c167ef7ff3a4785f5faed9b0a4f98)
---
 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?69f27b6a.18d0b.442cf296>