From: Jiri Pirko <[email protected]>

Currently the flags, which are unused, are validated for all heaps.
Since the follow-up patch introduces a flag valid for only one of the
heaps, allow to specify the valid flags per-heap.

Signed-off-by: Jiri Pirko <[email protected]>
---
 drivers/dma-buf/dma-heap.c | 5 ++++-
 include/linux/dma-heap.h   | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
index 8ab49924f8b7..4751bcef4b19 100644
--- a/drivers/dma-buf/dma-heap.c
+++ b/drivers/dma-buf/dma-heap.c
@@ -28,6 +28,7 @@
  * @name:              used for debugging/device-node name
  * @ops:               ops struct for this heap
  * @priv:              private data for this heap
+ * @valid_heap_flags:  valid heap flags for this heap
  * @heap_devt:         heap device node
  * @list:              list head connecting to list of heaps
  * @heap_cdev:         heap char device
@@ -38,6 +39,7 @@ struct dma_heap {
        const char *name;
        const struct dma_heap_ops *ops;
        void *priv;
+       u64 valid_heap_flags;
        dev_t heap_devt;
        struct list_head list;
        struct cdev heap_cdev;
@@ -105,7 +107,7 @@ static long dma_heap_ioctl_allocate(struct file *file, void 
*data)
        if (heap_allocation->fd_flags & ~DMA_HEAP_VALID_FD_FLAGS)
                return -EINVAL;
 
-       if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS)
+       if (heap_allocation->heap_flags & ~heap->valid_heap_flags)
                return -EINVAL;
 
        fd = dma_heap_buffer_alloc(heap, heap_allocation->len,
@@ -246,6 +248,7 @@ struct dma_heap *dma_heap_add(const struct 
dma_heap_export_info *exp_info)
        heap->name = exp_info->name;
        heap->ops = exp_info->ops;
        heap->priv = exp_info->priv;
+       heap->valid_heap_flags = exp_info->valid_heap_flags;
 
        /* Find unused minor number */
        ret = xa_alloc(&dma_heap_minors, &minor, heap,
diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h
index 27d15f60950a..7cfb531a9281 100644
--- a/include/linux/dma-heap.h
+++ b/include/linux/dma-heap.h
@@ -31,6 +31,7 @@ struct dma_heap_ops {
  * @name:      used for debugging/device-node name
  * @ops:       ops struct for this heap
  * @priv:      heap exporter private data
+ * @valid_heap_flags:  valid heap flags for this heap
  *
  * Information needed to export a new dmabuf heap.
  */
@@ -38,6 +39,7 @@ struct dma_heap_export_info {
        const char *name;
        const struct dma_heap_ops *ops;
        void *priv;
+       u64 valid_heap_flags;
 };
 
 void *dma_heap_get_drvdata(struct dma_heap *heap);
-- 
2.51.1

Reply via email to