From: Hans Verkuil hans.verk...@cisco.com
The 'write' argument is very ambiguous. I first assumed that if it is 1,
then we're doing video output but instead it meant the reverse.
Since it is used to setup the dma_dir value anyway it is now replaced by
the correct dma_dir value which is unambiguous.
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
drivers/media/v4l2-core/videobuf2-core.c | 15 +
drivers/media/v4l2-core/videobuf2-dma-contig.c | 46 ++
drivers/media/v4l2-core/videobuf2-dma-sg.c | 46 --
drivers/media/v4l2-core/videobuf2-vmalloc.c| 20 ++-
include/media/videobuf2-core.h | 11 +++---
5 files changed, 73 insertions(+), 65 deletions(-)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c
b/drivers/media/v4l2-core/videobuf2-core.c
index 490defb..7aed8f2 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -189,7 +189,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q);
static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
{
struct vb2_queue *q = vb-vb2_queue;
- int write = !V4L2_TYPE_IS_OUTPUT(q-type);
+ enum dma_data_direction dma_dir =
+ V4L2_TYPE_IS_OUTPUT(q-type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
void *mem_priv;
int plane;
@@ -201,7 +202,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
unsigned long size = PAGE_ALIGN(q-plane_sizes[plane]);
mem_priv = call_ptr_memop(vb, alloc, q-alloc_ctx[plane],
- size, write, q-gfp_flags);
+ size, dma_dir, q-gfp_flags);
if (IS_ERR_OR_NULL(mem_priv))
goto free;
@@ -1359,7 +1360,8 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const
struct v4l2_buffer *b)
void *mem_priv;
unsigned int plane;
int ret;
- int write = !V4L2_TYPE_IS_OUTPUT(q-type);
+ enum dma_data_direction dma_dir =
+ V4L2_TYPE_IS_OUTPUT(q-type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
bool reacquired = vb-planes[0].mem_priv == NULL;
memset(planes, 0, sizeof(planes[0]) * vb-num_planes);
@@ -1401,7 +1403,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const
struct v4l2_buffer *b)
/* Acquire each plane's memory */
mem_priv = call_ptr_memop(vb, get_userptr, q-alloc_ctx[plane],
planes[plane].m.userptr,
- planes[plane].length, write);
+ planes[plane].length, dma_dir);
if (IS_ERR_OR_NULL(mem_priv)) {
dprintk(1, failed acquiring userspace
memory for plane %d\n, plane);
@@ -1462,7 +1464,8 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const
struct v4l2_buffer *b)
void *mem_priv;
unsigned int plane;
int ret;
- int write = !V4L2_TYPE_IS_OUTPUT(q-type);
+ enum dma_data_direction dma_dir =
+ V4L2_TYPE_IS_OUTPUT(q-type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
bool reacquired = vb-planes[0].mem_priv == NULL;
memset(planes, 0, sizeof(planes[0]) * vb-num_planes);
@@ -1510,7 +1513,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const
struct v4l2_buffer *b)
/* Acquire each plane's memory */
mem_priv = call_ptr_memop(vb, attach_dmabuf,
q-alloc_ctx[plane],
- dbuf, planes[plane].length, write);
+ dbuf, planes[plane].length, dma_dir);
if (IS_ERR(mem_priv)) {
dprintk(1, failed to attach dmabuf\n);
ret = PTR_ERR(mem_priv);
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c
b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 6675f12..c4305bf 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -155,8 +155,8 @@ static void vb2_dc_put(void *buf_priv)
kfree(buf);
}
-static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, int write,
- gfp_t gfp_flags)
+static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
+ enum dma_data_direction dma_dir, gfp_t gfp_flags)
{
struct vb2_dc_conf *conf = alloc_ctx;
struct device *dev = conf-dev;
@@ -177,7 +177,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long
size, int write,
/* Prevent the device from being released while the buffer is used */
buf-dev = get_device(dev);
buf-size = size;
- buf-dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
+ buf-dma_dir = dma_dir;
buf-handler.refcount = buf-refcount;
buf-handler.put = vb2_dc_put;
@@ -231,7 +231,7 @@ static int vb2_dc_mmap(void