]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dma-buf: add get_dma_buf()
authorRob Clark <rob@ti.com>
Fri, 16 Mar 2012 16:04:41 +0000 (11:04 -0500)
committerSumit Semwal <sumit.semwal@ti.com>
Sun, 18 Mar 2012 09:37:37 +0000 (15:07 +0530)
Works in a similar way to get_file(), and is needed in cases such as
when the exporter needs to also keep a reference to the dmabuf (that
is later released with a dma_buf_put()), and possibly other similar
cases.

Signed-off-by: Rob Clark <rob@ti.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
include/linux/dma-buf.h

index 891457a86b30ba59a2faf5fbdf8b3850a558e9f0..bc4203dc6e182419a5ea2dc4cc4bb891e2726c41 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/scatterlist.h>
 #include <linux/list.h>
 #include <linux/dma-mapping.h>
+#include <linux/fs.h>
 
 struct dma_buf;
 struct dma_buf_attachment;
@@ -110,6 +111,20 @@ struct dma_buf_attachment {
        void *priv;
 };
 
+/**
+ * get_dma_buf - convenience wrapper for get_file.
+ * @dmabuf:    [in]    pointer to dma_buf
+ *
+ * Increments the reference count on the dma-buf, needed in case of drivers
+ * that either need to create additional references to the dmabuf on the
+ * kernel side.  For example, an exporter that needs to keep a dmabuf ptr
+ * so that subsequent exports don't create a new dmabuf.
+ */
+static inline void get_dma_buf(struct dma_buf *dmabuf)
+{
+       get_file(dmabuf->file);
+}
+
 #ifdef CONFIG_DMA_SHARED_BUFFER
 struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
                                                        struct device *dev);