object.c (a01ca78c8f118e5a24f1527ecf078ab56ddd4805) object.c (bf81df9be28657eea4aca8c6ab4ed3e69f8a051c)
1/*
2 * Copyright 2014 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the

--- 22 unchanged lines hidden (view full) ---

31nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
32{
33 struct nvif_client *client = object->client;
34 union {
35 struct nvif_ioctl_v0 v0;
36 } *args = data;
37
38 if (size >= sizeof(*args) && args->v0.version == 0) {
1/*
2 * Copyright 2014 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the

--- 22 unchanged lines hidden (view full) ---

31nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
32{
33 struct nvif_client *client = object->client;
34 union {
35 struct nvif_ioctl_v0 v0;
36 } *args = data;
37
38 if (size >= sizeof(*args) && args->v0.version == 0) {
39 if (object != &client->object)
40 args->v0.object = nvif_handle(object);
41 else
42 args->v0.object = 0;
39 args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY;
43 args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY;
40 args->v0.path_nr = 0;
41 while (args->v0.path_nr < ARRAY_SIZE(args->v0.path)) {
42 args->v0.path[args->v0.path_nr++] = object->handle;
43 if (object->parent == object)
44 break;
45 object = object->parent;
46 }
47 } else
48 return -ENOSYS;
49
50 return client->driver->ioctl(client->object.priv, client->super,
51 data, size, hack);
52}
53
54int

--- 156 unchanged lines hidden (view full) ---

211{
212 struct {
213 struct nvif_ioctl_v0 ioctl;
214 struct nvif_ioctl_new_v0 new;
215 } *args;
216 int ret = 0;
217
218 object->client = NULL;
44 } else
45 return -ENOSYS;
46
47 return client->driver->ioctl(client->object.priv, client->super,
48 data, size, hack);
49}
50
51int

--- 156 unchanged lines hidden (view full) ---

208{
209 struct {
210 struct nvif_ioctl_v0 ioctl;
211 struct nvif_ioctl_new_v0 new;
212 } *args;
213 int ret = 0;
214
215 object->client = NULL;
219 object->parent = parent;
220 object->handle = handle;
221 object->oclass = oclass;
222 object->map.ptr = NULL;
223 object->map.size = 0;
224
216 object->handle = handle;
217 object->oclass = oclass;
218 object->map.ptr = NULL;
219 object->map.size = 0;
220
225 if (object->parent) {
221 if (parent) {
226 if (!(args = kmalloc(sizeof(*args) + size, GFP_KERNEL))) {
227 nvif_object_fini(object);
228 return -ENOMEM;
229 }
230
231 args->ioctl.version = 0;
232 args->ioctl.type = NVIF_IOCTL_V0_NEW;
233 args->new.version = 0;
234 args->new.route = parent->client->route;
222 if (!(args = kmalloc(sizeof(*args) + size, GFP_KERNEL))) {
223 nvif_object_fini(object);
224 return -ENOMEM;
225 }
226
227 args->ioctl.version = 0;
228 args->ioctl.type = NVIF_IOCTL_V0_NEW;
229 args->new.version = 0;
230 args->new.route = parent->client->route;
235 args->new.token = (unsigned long)(void *)object;
231 args->new.token = nvif_handle(object);
232 args->new.object = nvif_handle(object);
236 args->new.handle = handle;
237 args->new.oclass = oclass;
238
239 memcpy(args->new.data, data, size);
240 ret = nvif_object_ioctl(parent, args, sizeof(*args) + size,
241 &object->priv);
242 memcpy(data, args->new.data, size);
243 kfree(args);
244 if (ret == 0)
245 object->client = parent->client;
246 }
247
248 if (ret)
249 nvif_object_fini(object);
250 return ret;
251}
233 args->new.handle = handle;
234 args->new.oclass = oclass;
235
236 memcpy(args->new.data, data, size);
237 ret = nvif_object_ioctl(parent, args, sizeof(*args) + size,
238 &object->priv);
239 memcpy(data, args->new.data, size);
240 kfree(args);
241 if (ret == 0)
242 object->client = parent->client;
243 }
244
245 if (ret)
246 nvif_object_fini(object);
247 return ret;
248}