History

drm/syncobj: add a new helper drm_syncobj_get_fd

Marek Olšák committed 9 years ago

Commit 684fd0a1 parent 1321fd22 files · +20 −14Browse files

Unified · Split

2 files
  1. drivers/gpu/drm/drm_syncobj.c +19 −14
  2. include/drm/drm_syncobj.h +1 −0
drivers/gpu/drm/drm_syncobj.c+19−14
@@ -386,33 +386,38 @@ static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj) · 385 unmodified lines
386386 return 0;
387387 }
388388
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)
391390 {
392− struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
393391 int ret;
394392 int fd;
395393
396− if (!syncobj)
397− return -EINVAL;
398−
399394 fd = get_unused_fd_flags(O_CLOEXEC);
400− if (fd < 0) {
401− drm_syncobj_put(syncobj);
395+ if (fd < 0)
402396 return fd;
403− }
404397
405398 if (!syncobj->file) {
406399 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+ }
409404 }
410405 fd_install(fd, syncobj->file);
411− drm_syncobj_put(syncobj);
412406 *p_fd = fd;
413407 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);
416421 drm_syncobj_put(syncobj);
417422 return ret;
418423 }
include/drm/drm_syncobj.h+1−0
@@ -140,5 +140,6 @@ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, · 139 unmodified lines
140140 struct dma_fence *fence);
141141 int drm_syncobj_get_handle(struct drm_file *file_private,
142142 struct drm_syncobj *syncobj, u32 *handle);
143+int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
143144
144145 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t