summaryrefslogtreecommitdiffstats
path: root/drivers/dma-buf
diff options
context:
space:
mode:
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>2016-08-05 10:39:36 -0300
committerSumit Semwal <sumit.semwal@linaro.org>2016-08-11 15:33:24 +0530
commit972526a4093243fdaf77dd7c6f8b11fba5b15864 (patch)
tree49121dcbbcec8f6c7acc8cd6762395e81183c18b /drivers/dma-buf
parenta02b9dc90d844cc7df7b63264e7920cc425052d9 (diff)
downloadop-kernel-dev-972526a4093243fdaf77dd7c6f8b11fba5b15864.zip
op-kernel-dev-972526a4093243fdaf77dd7c6f8b11fba5b15864.tar.gz
dma-buf/sync_file: add sync_file_get_fence()
Creates a function that given an sync file descriptor returns a fence containing all fences in the sync_file. v2: Comments by Daniel Vetter - Adapt to new version of fence_collection_init() - Hold a reference for the fence we return v3: - Adapt to use fput() directly - rename to sync_file_get_fence() as we always return one fence v4: Adapt to use fence_array v5: set fence through fence_get() Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r--drivers/dma-buf/sync_file.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index ac9c250..2873760 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -116,6 +116,29 @@ err:
return NULL;
}
+/**
+ * sync_file_get_fence - get the fence related to the sync_file fd
+ * @fd: sync_file fd to get the fence from
+ *
+ * Ensures @fd references a valid sync_file and returns a fence that
+ * represents all fence in the sync_file. On error NULL is returned.
+ */
+struct fence *sync_file_get_fence(int fd)
+{
+ struct sync_file *sync_file;
+ struct fence *fence;
+
+ sync_file = sync_file_fdget(fd);
+ if (!sync_file)
+ return NULL;
+
+ fence = fence_get(sync_file->fence);
+ fput(sync_file->file);
+
+ return fence;
+}
+EXPORT_SYMBOL(sync_file_get_fence);
+
static int sync_file_set_fence(struct sync_file *sync_file,
struct fence **fences, int num_fences)
{
OpenPOWER on IntegriCloud