drm/nouveau/core/client: lookup client objects with nvkm_object_search()
authorBen Skeggs <bskeggs@redhat.com>
Thu, 22 Dec 2016 05:23:04 +0000 (15:23 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 17 Feb 2017 05:14:56 +0000 (15:14 +1000)
Custom code is no longer needed here.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/core/client.h
drivers/gpu/drm/nouveau/nvkm/core/client.c
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c

index 99083349c3d41433a9564f310b75fed44257469d..361ad8cee02ce084dfc6a3e12d2f654388661353 100644 (file)
@@ -19,10 +19,6 @@ struct nvkm_client {
        struct nvkm_vm *vm;
 };
 
-bool nvkm_client_insert(struct nvkm_client *, struct nvkm_object *);
-void nvkm_client_remove(struct nvkm_client *, struct nvkm_object *);
-struct nvkm_object *nvkm_client_search(struct nvkm_client *, u64 object);
-
 int  nvkm_client_new(const char *name, u64 device, const char *cfg,
                     const char *dbg, struct nvkm_client **);
 void nvkm_client_del(struct nvkm_client **);
index e1943910858e5f9fb46ecb3c6ff2b77bdf80e847..0c2fdf14201ef46516c67409028ab31415f44024 100644 (file)
@@ -206,55 +206,6 @@ nvkm_client_object_func = {
        .sclass = nvkm_client_child_get,
 };
 
-void
-nvkm_client_remove(struct nvkm_client *client, struct nvkm_object *object)
-{
-       if (!RB_EMPTY_NODE(&object->node))
-               rb_erase(&object->node, &client->objroot);
-}
-
-bool
-nvkm_client_insert(struct nvkm_client *client, struct nvkm_object *object)
-{
-       struct rb_node **ptr = &client->objroot.rb_node;
-       struct rb_node *parent = NULL;
-
-       while (*ptr) {
-               struct nvkm_object *this =
-                       container_of(*ptr, typeof(*this), node);
-               parent = *ptr;
-               if (object->object < this->object)
-                       ptr = &parent->rb_left;
-               else
-               if (object->object > this->object)
-                       ptr = &parent->rb_right;
-               else
-                       return false;
-       }
-
-       rb_link_node(&object->node, parent, ptr);
-       rb_insert_color(&object->node, &client->objroot);
-       return true;
-}
-
-struct nvkm_object *
-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);
-               if (handle < object->object)
-                       node = node->rb_left;
-               else
-               if (handle > object->object)
-                       node = node->rb_right;
-               else
-                       return object;
-       }
-       return NULL;
-}
-
 int
 nvkm_client_fini(struct nvkm_client *client, bool suspend)
 {
index b0db51847c361efabb336e28d21007c1d81dccc8..6e695b7a5733ccc157e7f15bcf0a31712966cc43 100644 (file)
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size)
                        object->route = args->v0.route;
                        object->token = args->v0.token;
                        object->object = args->v0.object;
-                       if (nvkm_client_insert(client, object)) {
+                       if (nvkm_object_insert(object)) {
                                client->data = object;
                                return 0;
                        }
@@ -389,13 +389,10 @@ nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
        struct nvkm_object *object;
        int ret;
 
-       if (handle)
-               object = nvkm_client_search(client, handle);
-       else
-               object = &client->object;
-       if (unlikely(!object)) {
+       object = nvkm_object_search(client, handle, NULL);
+       if (IS_ERR(object)) {
                nvif_ioctl(&client->object, "object not found\n");
-               return -ENOENT;
+               return PTR_ERR(object);
        }
 
        if (owner != NVIF_IOCTL_V0_OWNER_ANY && owner != object->route) {