diff options
author | Elena Reshetova <elena.reshetova@intel.com> | 2017-03-06 17:21:00 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-04-05 21:31:57 +0300 |
commit | 6c4bb65d0be8f34bc0aba982c9a47b19a1eea5ed (patch) | |
tree | 37e956f83c6ba7e2870172f6c540b3a3a4f9aee9 /drivers/media/v4l2-core/videobuf2-dma-contig.c | |
parent | a8d8e38a9337cc6b46ef6c66db65130fb61050dd (diff) | |
download | linux-6c4bb65d0be8f34bc0aba982c9a47b19a1eea5ed.tar.xz |
[media] vb2: convert vb2_vmarea_handler refcount from atomic_t to refcount_t
Use refcount_t to manage the refcount to the memory type specific buffer
videobuf2 buffer implementations. refcount_t is better suitable for the
purpose than atomic_t.
Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David Windsor <dwindsor@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf2-dma-contig.c')
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-contig.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index fb6a177be461..d29a07f3b048 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -12,6 +12,7 @@ #include <linux/dma-buf.h> #include <linux/module.h> +#include <linux/refcount.h> #include <linux/scatterlist.h> #include <linux/sched.h> #include <linux/slab.h> @@ -34,7 +35,7 @@ struct vb2_dc_buf { /* MMAP related */ struct vb2_vmarea_handler handler; - atomic_t refcount; + refcount_t refcount; struct sg_table *sgt_base; /* DMABUF related */ @@ -86,7 +87,7 @@ static unsigned int vb2_dc_num_users(void *buf_priv) { struct vb2_dc_buf *buf = buf_priv; - return atomic_read(&buf->refcount); + return refcount_read(&buf->refcount); } static void vb2_dc_prepare(void *buf_priv) @@ -122,7 +123,7 @@ static void vb2_dc_put(void *buf_priv) { struct vb2_dc_buf *buf = buf_priv; - if (!atomic_dec_and_test(&buf->refcount)) + if (!refcount_dec_and_test(&buf->refcount)) return; if (buf->sgt_base) { @@ -170,7 +171,7 @@ static void *vb2_dc_alloc(struct device *dev, unsigned long attrs, buf->handler.put = vb2_dc_put; buf->handler.arg = buf; - atomic_inc(&buf->refcount); + refcount_set(&buf->refcount, 1); return buf; } @@ -407,7 +408,7 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, unsigned long flags) return NULL; /* dmabuf keeps reference to vb2 buffer */ - atomic_inc(&buf->refcount); + refcount_inc(&buf->refcount); return dbuf; } |