diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-07-21 15:14:02 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-24 16:10:40 +0300 |
commit | 0ff657b0f6120cb53f98b1b42c87af34670edff5 (patch) | |
tree | 9baee4a0202c7a51056e016f16bcfb575a1133da /drivers/media/v4l2-core/videobuf2-dma-sg.c | |
parent | 82019205e3a8fc687c4ee6538b57039884be4ccc (diff) | |
download | linux-0ff657b0f6120cb53f98b1b42c87af34670edff5.tar.xz |
[media] vb2: don't return NULL for alloc and get_userptr ops
Always return an ERR_PTR() instead of NULL.
This makes the behavior of alloc, get_userptr and attach_dmabuf the
same.
Update the documentation in videobuf2-core.h as well.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf2-dma-sg.c')
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-sg.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index bd82d709ee82..e0165c10b82f 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -104,11 +104,12 @@ static void *vb2_dma_sg_alloc(struct device *dev, unsigned long dma_attrs, int ret; int num_pages; - if (WARN_ON(dev == NULL)) - return NULL; + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) - return NULL; + return ERR_PTR(-ENOMEM); buf->vaddr = NULL; buf->dma_dir = dma_dir; @@ -166,7 +167,7 @@ fail_pages_alloc: kfree(buf->pages); fail_pages_array_alloc: kfree(buf); - return NULL; + return ERR_PTR(-ENOMEM); } static void vb2_dma_sg_put(void *buf_priv) @@ -226,7 +227,7 @@ static void *vb2_dma_sg_get_userptr(struct device *dev, unsigned long vaddr, buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) - return NULL; + return ERR_PTR(-ENOMEM); buf->vaddr = NULL; buf->dev = dev; @@ -266,7 +267,7 @@ userptr_fail_sgtable: vb2_destroy_framevec(vec); userptr_fail_pfnvec: kfree(buf); - return NULL; + return ERR_PTR(-ENOMEM); } /* |