[Nouveau] [PATCH] drm/nouveau/client: use rb_entry()

Geliang Tang geliangtang at gmail.com
Fri Jan 20 14:36:56 UTC 2017


To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangtang at gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/core/client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index e194391..ab2ee14 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -221,7 +221,7 @@ nvkm_client_insert(struct nvkm_client *client, struct nvkm_object *object)
 
 	while (*ptr) {
 		struct nvkm_object *this =
-			container_of(*ptr, typeof(*this), node);
+			rb_entry(*ptr, typeof(*this), node);
 		parent = *ptr;
 		if (object->object < this->object)
 			ptr = &parent->rb_left;
@@ -243,7 +243,7 @@ nvkm_client_search(struct nvkm_client *client, u64 handle)
 	struct rb_node *node = client->objroot.rb_node;
 	while (node) {
 		struct nvkm_object *object =
-			container_of(node, typeof(*object), node);
+			rb_entry(node, typeof(*object), node);
 		if (handle < object->object)
 			node = node->rb_left;
 		else
-- 
2.9.3



More information about the Nouveau mailing list