Unified · Split
| @@ -386,33 +386,38 @@ static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj) · 385 unmodified lines | ||
| 386 | 386 | return 0; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | −static int drm_syncobj_handle_to_fd(struct drm_file *file_private, | |
| 390 | − u32 handle, int *p_fd) | |
| 389 | +int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd) | |
| 391 | 390 | { |
| 392 | − struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle); | |
| 393 | 391 | int ret; |
| 394 | 392 | int fd; |
| 395 | 393 | |
| 396 | − if (!syncobj) | |
| 397 | − return -EINVAL; | |
| 398 | − | |
| 399 | 394 | fd = get_unused_fd_flags(O_CLOEXEC); |
| 400 | − if (fd < 0) { | |
| 401 | − drm_syncobj_put(syncobj); | |
| 395 | + if (fd < 0) | |
| 402 | 396 | return fd; |
| 403 | − } | |
| 404 | 397 | |
| 405 | 398 | if (!syncobj->file) { |
| 406 | 399 | ret = drm_syncobj_alloc_file(syncobj); |
| 407 | − if (ret) | |
| 408 | − goto out_put_fd; | |
| 400 | + if (ret) { | |
| 401 | + put_unused_fd(fd); | |
| 402 | + return ret; | |
| 403 | + } | |
| 409 | 404 | } |
| 410 | 405 | fd_install(fd, syncobj->file); |
| 411 | − drm_syncobj_put(syncobj); | |
| 412 | 406 | *p_fd = fd; |
| 413 | 407 | return 0; |
| 414 | −out_put_fd: | |
| 415 | − put_unused_fd(fd); | |
| 408 | +} | |
| 409 | +EXPORT_SYMBOL(drm_syncobj_get_fd); | |
| 410 | + | |
| 411 | +static int drm_syncobj_handle_to_fd(struct drm_file *file_private, | |
| 412 | + u32 handle, int *p_fd) | |
| 413 | +{ | |
| 414 | + struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle); | |
| 415 | + int ret; | |
| 416 | + | |
| 417 | + if (!syncobj) | |
| 418 | + return -EINVAL; | |
| 419 | + | |
| 420 | + ret = drm_syncobj_get_fd(syncobj, p_fd); | |
| 416 | 421 | drm_syncobj_put(syncobj); |
| 417 | 422 | return ret; |
| 418 | 423 | } |
| @@ -140,5 +140,6 @@ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, · 139 unmodified lines | ||
| 140 | 140 | struct dma_fence *fence); |
| 141 | 141 | int drm_syncobj_get_handle(struct drm_file *file_private, |
| 142 | 142 | struct drm_syncobj *syncobj, u32 *handle); |
| 143 | +int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd); | |
| 143 | 144 | |
| 144 | 145 | #endif |