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

Ben Skeggs skeggsb at gmail.com
Sat Jan 21 00:14:57 UTC 2017


On 01/21/2017 12:36 AM, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
Hey Geliang,

Looks good, however, I've already got a patch handling this pending in
my tree.

Thank you!
Ben.

> 
> 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
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20170121/33208184/attachment.sig>


More information about the Nouveau mailing list