dma-buf: make map_atomic and map function pointers optional
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 29 May 2018 13:59:18 +0000 (15:59 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 1 Jun 2018 06:59:35 +0000 (08:59 +0200)
So drivers don't need dummy functions just returning NULL.

Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180529135918.19729-1-kraxel@redhat.com
drivers/dma-buf/dma-buf.c
include/linux/dma-buf.h

index d78d5fc173dc3d9b05b523462301a060e5482473..4c45e31258f0431dc33e8a966a9a0b4244ab0b1f 100644 (file)
@@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num)
 {
        WARN_ON(!dmabuf);
 
+       if (!dmabuf->ops->map_atomic)
+               return NULL;
        return dmabuf->ops->map_atomic(dmabuf, page_num);
 }
 EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
@@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num)
 {
        WARN_ON(!dmabuf);
 
+       if (!dmabuf->ops->map)
+               return NULL;
        return dmabuf->ops->map(dmabuf, page_num);
 }
 EXPORT_SYMBOL_GPL(dma_buf_kmap);
index 085db2fee2d71b603bee462dc29c7cccb4010866..88917fa796e44a2cc5ac960d951e99c747152ad7 100644 (file)
@@ -39,12 +39,12 @@ struct dma_buf_attachment;
 
 /**
  * struct dma_buf_ops - operations possible on struct dma_buf
- * @map_atomic: maps a page from the buffer into kernel address
+ * @map_atomic: [optional] maps a page from the buffer into kernel address
  *             space, users may not block until the subsequent unmap call.
  *             This callback must not sleep.
  * @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer.
  *               This Callback must not sleep.
- * @map: maps a page from the buffer into kernel address space.
+ * @map: [optional] maps a page from the buffer into kernel address space.
  * @unmap: [optional] unmaps a page from the buffer.
  * @vmap: [optional] creates a virtual mapping for the buffer into kernel
  *       address space. Same restrictions as for vmap and friends apply.