Commit 09ea0dfb authored by Gerd Hoffmann's avatar Gerd Hoffmann

dma-buf: make map_atomic and map function pointers optional

So drivers don't need dummy functions just returning NULL.

Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180529135918.19729-1-kraxel@redhat.com
parent e065a8dd
...@@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num) ...@@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num)
{ {
WARN_ON(!dmabuf); WARN_ON(!dmabuf);
if (!dmabuf->ops->map_atomic)
return NULL;
return dmabuf->ops->map_atomic(dmabuf, page_num); return dmabuf->ops->map_atomic(dmabuf, page_num);
} }
EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic); EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
...@@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num) ...@@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num)
{ {
WARN_ON(!dmabuf); WARN_ON(!dmabuf);
if (!dmabuf->ops->map)
return NULL;
return dmabuf->ops->map(dmabuf, page_num); return dmabuf->ops->map(dmabuf, page_num);
} }
EXPORT_SYMBOL_GPL(dma_buf_kmap); EXPORT_SYMBOL_GPL(dma_buf_kmap);
......
...@@ -39,12 +39,12 @@ struct dma_buf_attachment; ...@@ -39,12 +39,12 @@ struct dma_buf_attachment;
/** /**
* struct dma_buf_ops - operations possible on struct dma_buf * 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. * space, users may not block until the subsequent unmap call.
* This callback must not sleep. * This callback must not sleep.
* @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer. * @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer.
* This Callback must not sleep. * 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. * @unmap: [optional] unmaps a page from the buffer.
* @vmap: [optional] creates a virtual mapping for the buffer into kernel * @vmap: [optional] creates a virtual mapping for the buffer into kernel
* address space. Same restrictions as for vmap and friends apply. * address space. Same restrictions as for vmap and friends apply.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment