diff options
author | Ben Skeggs | 2015-11-23 22:36:48 -0600 |
---|---|---|
committer | Ben Skeggs | 2015-12-21 21:22:07 -0600 |
commit | 0996ad0e12a25841f350b8c5cacccff3d0aa24d2 (patch) | |
tree | 95942c8724139344778a38c8a30415789c0423a0 | |
parent | 4a3cbf5c0a38adf41d637c5d7273480336df39d0 (diff) | |
download | external-libdrm-0996ad0e12a25841f350b8c5cacccff3d0aa24d2.tar.gz external-libdrm-0996ad0e12a25841f350b8c5cacccff3d0aa24d2.tar.xz external-libdrm-0996ad0e12a25841f350b8c5cacccff3d0aa24d2.zip |
nouveau: move object functions up, to avoid future foward decls
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r-- | nouveau/nouveau.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c index 8a0be2fa..8035c6a0 100644 --- a/nouveau/nouveau.c +++ b/nouveau/nouveau.c | |||
@@ -59,6 +59,62 @@ debug_init(char *args) | |||
59 | } | 59 | } |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | int | ||
63 | nouveau_object_new(struct nouveau_object *parent, uint64_t handle, | ||
64 | uint32_t oclass, void *data, uint32_t length, | ||
65 | struct nouveau_object **pobj) | ||
66 | { | ||
67 | struct nouveau_object *obj; | ||
68 | int (*func)(struct nouveau_object *); | ||
69 | int ret = -EINVAL; | ||
70 | |||
71 | if (length == 0) | ||
72 | length = sizeof(struct nouveau_object *); | ||
73 | obj = malloc(sizeof(*obj) + length); | ||
74 | obj->parent = parent; | ||
75 | obj->handle = handle; | ||
76 | obj->oclass = oclass; | ||
77 | obj->length = length; | ||
78 | obj->data = obj + 1; | ||
79 | if (data) | ||
80 | memcpy(obj->data, data, length); | ||
81 | *(struct nouveau_object **)obj->data = obj; | ||
82 | |||
83 | abi16_object(obj, &func); | ||
84 | if (func) | ||
85 | ret = func(obj); | ||
86 | |||
87 | if (ret) { | ||
88 | free(obj); | ||
89 | return ret; | ||
90 | } | ||
91 | |||
92 | *pobj = obj; | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | void | ||
97 | nouveau_object_del(struct nouveau_object **pobj) | ||
98 | { | ||
99 | struct nouveau_object *obj = *pobj; | ||
100 | if (obj) { | ||
101 | abi16_delete(obj); | ||
102 | free(obj); | ||
103 | *pobj = NULL; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | void * | ||
108 | nouveau_object_find(struct nouveau_object *obj, uint32_t pclass) | ||
109 | { | ||
110 | while (obj && obj->oclass != pclass) { | ||
111 | obj = obj->parent; | ||
112 | if (pclass == NOUVEAU_PARENT_CLASS) | ||
113 | break; | ||
114 | } | ||
115 | return obj; | ||
116 | } | ||
117 | |||
62 | /* this is the old libdrm's version of nouveau_device_wrap(), the symbol | 118 | /* this is the old libdrm's version of nouveau_device_wrap(), the symbol |
63 | * is kept here to prevent AIGLX from crashing if the DDX is linked against | 119 | * is kept here to prevent AIGLX from crashing if the DDX is linked against |
64 | * the new libdrm, but the DRI driver against the old | 120 | * the new libdrm, but the DRI driver against the old |
@@ -247,62 +303,6 @@ nouveau_client_del(struct nouveau_client **pclient) | |||
247 | } | 303 | } |
248 | } | 304 | } |
249 | 305 | ||
250 | int | ||
251 | nouveau_object_new(struct nouveau_object *parent, uint64_t handle, | ||
252 | uint32_t oclass, void *data, uint32_t length, | ||
253 | struct nouveau_object **pobj) | ||
254 | { | ||
255 | struct nouveau_object *obj; | ||
256 | int (*func)(struct nouveau_object *); | ||
257 | int ret = -EINVAL; | ||
258 | |||
259 | if (length == 0) | ||
260 | length = sizeof(struct nouveau_object *); | ||
261 | obj = malloc(sizeof(*obj) + length); | ||
262 | obj->parent = parent; | ||
263 | obj->handle = handle; | ||
264 | obj->oclass = oclass; | ||
265 | obj->length = length; | ||
266 | obj->data = obj + 1; | ||
267 | if (data) | ||
268 | memcpy(obj->data, data, length); | ||
269 | *(struct nouveau_object **)obj->data = obj; | ||
270 | |||
271 | abi16_object(obj, &func); | ||
272 | if (func) | ||
273 | ret = func(obj); | ||
274 | |||
275 | if (ret) { | ||
276 | free(obj); | ||
277 | return ret; | ||
278 | } | ||
279 | |||
280 | *pobj = obj; | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | void | ||
285 | nouveau_object_del(struct nouveau_object **pobj) | ||
286 | { | ||
287 | struct nouveau_object *obj = *pobj; | ||
288 | if (obj) { | ||
289 | abi16_delete(obj); | ||
290 | free(obj); | ||
291 | *pobj = NULL; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | void * | ||
296 | nouveau_object_find(struct nouveau_object *obj, uint32_t pclass) | ||
297 | { | ||
298 | while (obj && obj->oclass != pclass) { | ||
299 | obj = obj->parent; | ||
300 | if (pclass == NOUVEAU_PARENT_CLASS) | ||
301 | break; | ||
302 | } | ||
303 | return obj; | ||
304 | } | ||
305 | |||
306 | static void | 306 | static void |
307 | nouveau_bo_del(struct nouveau_bo *bo) | 307 | nouveau_bo_del(struct nouveau_bo *bo) |
308 | { | 308 | { |