drm/nouveau/core/client: lookup client objects with nvkm_object_search()
Custom code is no longer needed here. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
parent
110cccff95
commit
daad3dfb05
|
@ -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 **);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue