dma-buf: add release callback support
[firefly-linux-kernel-4.4.55.git] / include / linux / dma-buf.h
index f98bd7068d55a3f4ddfdb50dc01d95909ab30f45..d58bd33d643576ae7347ae6ac58b5ff8685762fe 100644 (file)
@@ -90,6 +90,9 @@ struct dma_buf_ops {
         * if the call would block.
         */
 
+       int (*set_release_callback)(void (*release_callback)(void *data),
+                                   void *data);
+       void *(*get_release_callback_data)(void *callback);
        /* after final dma_buf_put() */
        void (*release)(struct dma_buf *);
 
@@ -125,6 +128,7 @@ struct dma_buf {
        size_t size;
        struct file *file;
        struct list_head attachments;
+       struct list_head release_callbacks;
        const struct dma_buf_ops *ops;
        /* mutex to serialize list manipulation, attach/detach and vmap/unmap */
        struct mutex lock;
@@ -209,6 +213,12 @@ static inline void get_dma_buf(struct dma_buf *dmabuf)
        get_file(dmabuf->file);
 }
 
+int dma_buf_set_release_callback(struct dma_buf *dmabuf,
+                                void (*callback)(void *), void *data);
+
+void *dma_buf_get_release_callback_data(struct dma_buf *dmabuf,
+                                       void (*callback)(void *));
+
 struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
                                                        struct device *dev);
 void dma_buf_detach(struct dma_buf *dmabuf,