[PATCH 2/8] sync_file: export some interfaces needed by drm sync objects.

Dave Airlie airlied at gmail.com
Tue Apr 11 03:22:14 UTC 2017


From: Dave Airlie <airlied at redhat.com>

These are just alloc and fdget interfaces needed by the drm sync
objects code.

Reviewed-by: Christian König <christian.koenig at amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 drivers/dma-buf/sync_file.c | 21 +++++++++++++++++++--
 include/linux/sync_file.h   |  3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index 07392af..50e635a 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -46,7 +46,16 @@ int sync_file_validate_type_flags(uint32_t type, uint32_t flags)
 }
 EXPORT_SYMBOL(sync_file_validate_type_flags);
 
-static struct sync_file *sync_file_alloc(uint32_t type, uint32_t flags)
+/**
+ * sync_file_alloc() - allocate an unfenced sync file
+ * @type: type of sync file object
+ * @flags: creation flags for sync file object
+ *
+ * Creates a sync_file.
+ * The sync_file can be released with fput(sync_file->file).
+ * Returns the sync_file or NULL in case of error.
+ */
+struct sync_file *sync_file_alloc(uint32_t type, uint32_t flags)
 {
 	struct sync_file *sync_file;
 	int ret;
@@ -78,6 +87,7 @@ static struct sync_file *sync_file_alloc(uint32_t type, uint32_t flags)
 	kfree(sync_file);
 	return NULL;
 }
+EXPORT_SYMBOL(sync_file_alloc);
 
 static void fence_check_cb_func(struct dma_fence *f, struct dma_fence_cb *cb)
 {
@@ -120,7 +130,13 @@ struct sync_file *sync_file_create(struct dma_fence *fence,
 }
 EXPORT_SYMBOL(sync_file_create);
 
-static struct sync_file *sync_file_fdget(int fd)
+/**
+ * sync_file_fdget - get a reference to the file and return sync_file.
+ * @fd: file descriptor pointing at a sync_file.
+ *
+ * Returns the corresponding sync_file object.
+ */
+struct sync_file *sync_file_fdget(int fd)
 {
 	struct file *file = fget(fd);
 
@@ -136,6 +152,7 @@ static struct sync_file *sync_file_fdget(int fd)
 	fput(file);
 	return NULL;
 }
+EXPORT_SYMBOL(sync_file_fdget);
 
 /**
  * sync_file_get_fence - get the fence related to the sync_file fd
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index ede4182..e683dd1 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -54,7 +54,8 @@ struct sync_file {
 #define POLL_ENABLED DMA_FENCE_FLAG_USER_BITS
 
 int sync_file_validate_type_flags(uint32_t type, uint32_t flags);
+struct sync_file *sync_file_alloc(uint32_t type, uint32_t flags);
 struct sync_file *sync_file_create(struct dma_fence *fence, uint32_t type, uint32_t flags);
 struct dma_fence *sync_file_get_fence(int fd);
-
+struct sync_file *sync_file_fdget(int fd);
 #endif /* _LINUX_SYNC_H */
-- 
2.9.3



More information about the dri-devel mailing list