[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <743102607e2c5fb20e3c0676fadbcb93d501a78e.1281100495.git.m.nazarewicz@samsung.com>
Date: Fri, 06 Aug 2010 15:22:07 +0200
From: Michal Nazarewicz <m.nazarewicz@...sung.com>
To: linux-mm@...ck.org
Cc: Hans Verkuil <hverkuil@...all.nl>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Daniel Walker <dwalker@...eaurora.org>,
Jonathan Corbet <corbet@....net>,
Pawel Osciak <p.osciak@...sung.com>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Hiremath Vaibhav <hvaibhav@...com>,
FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>,
Kyungmin Park <kyungmin.park@...sung.com>,
Zach Pfeffer <zpfeffer@...eaurora.org>,
Russell King <linux@....linux.org.uk>, jaeryul.oh@...sung.com,
kgene.kim@...sung.com, linux-arm-kernel@...ts.infradead.org,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Michal Nazarewicz <m.nazarewicz@...sung.com>
Subject: [PATCH/RFCv3 1/6] lib: rbtree: rb_root_init() function added
Added a rb_root_init() function which initialises a rb_root
structure as a red-black tree with at most one element. The
rationale is that using rb_root_init(root, node) is more
straightforward and cleaner then first initialising and
empty tree followed by an insert operation.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
include/linux/rbtree.h | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 7066acb..5b6dc66 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -130,6 +130,17 @@ static inline void rb_set_color(struct rb_node *rb, int color)
}
#define RB_ROOT (struct rb_root) { NULL, }
+
+static inline void rb_root_init(struct rb_root *root, struct rb_node *node)
+{
+ root->rb_node = node;
+ if (node) {
+ node->rb_parent_color = RB_BLACK; /* black, no parent */
+ node->rb_left = NULL;
+ node->rb_right = NULL;
+ }
+}
+
#define rb_entry(ptr, type, member) container_of(ptr, type, member)
#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists