aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-queue.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-08-22 20:03:11 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:36:53 -0400
commitb04bce476c57ac844962462ee4c813c44fa942cf (patch)
treefb08a484414e6e486fd31c59c8533c46fd4b1341 /drivers/media/video/cx18/cx18-queue.c
parent59ba2b002265f2e862aa7f0df3f13c09ea99c4da (diff)
V4L/DVB (8772): cx18: Convert cx18_queue buffers member to atomic_t
cx18: Convert cx18_queue buffers member to atomic_t. This allows safe concurrent access to check if a queue has data without having to acquire the queue spinlock. Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-queue.c')
-rw-r--r--drivers/media/video/cx18/cx18-queue.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index 4f3bd43ba802..a33ba04a2686 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -37,7 +37,7 @@ void cx18_buf_swap(struct cx18_buffer *buf)
37void cx18_queue_init(struct cx18_queue *q) 37void cx18_queue_init(struct cx18_queue *q)
38{ 38{
39 INIT_LIST_HEAD(&q->list); 39 INIT_LIST_HEAD(&q->list);
40 q->buffers = 0; 40 atomic_set(&q->buffers, 0);
41 q->bytesused = 0; 41 q->bytesused = 0;
42} 42}
43 43
@@ -54,7 +54,7 @@ void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
54 } 54 }
55 spin_lock_irqsave(&s->qlock, flags); 55 spin_lock_irqsave(&s->qlock, flags);
56 list_add_tail(&buf->list, &q->list); 56 list_add_tail(&buf->list, &q->list);
57 q->buffers++; 57 atomic_inc(&q->buffers);
58 q->bytesused += buf->bytesused - buf->readpos; 58 q->bytesused += buf->bytesused - buf->readpos;
59 spin_unlock_irqrestore(&s->qlock, flags); 59 spin_unlock_irqrestore(&s->qlock, flags);
60} 60}
@@ -68,7 +68,7 @@ struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q)
68 if (!list_empty(&q->list)) { 68 if (!list_empty(&q->list)) {
69 buf = list_entry(q->list.next, struct cx18_buffer, list); 69 buf = list_entry(q->list.next, struct cx18_buffer, list);
70 list_del_init(q->list.next); 70 list_del_init(q->list.next);
71 q->buffers--; 71 atomic_dec(&q->buffers);
72 q->bytesused -= buf->bytesused - buf->readpos; 72 q->bytesused -= buf->bytesused - buf->readpos;
73 } 73 }
74 spin_unlock_irqrestore(&s->qlock, flags); 74 spin_unlock_irqrestore(&s->qlock, flags);
@@ -92,8 +92,8 @@ struct cx18_buffer *cx18_queue_get_buf_irq(struct cx18_stream *s, u32 id,
92 /* the transport buffers are handled differently, 92 /* the transport buffers are handled differently,
93 they are not moved to the full queue */ 93 they are not moved to the full queue */
94 if (s->type != CX18_ENC_STREAM_TYPE_TS) { 94 if (s->type != CX18_ENC_STREAM_TYPE_TS) {
95 s->q_free.buffers--; 95 atomic_dec(&s->q_free.buffers);
96 s->q_full.buffers++; 96 atomic_inc(&s->q_full.buffers);
97 s->q_full.bytesused += buf->bytesused; 97 s->q_full.bytesused += buf->bytesused;
98 list_move_tail(&buf->list, &s->q_full.list); 98 list_move_tail(&buf->list, &s->q_full.list);
99 } 99 }
@@ -119,7 +119,7 @@ static void cx18_queue_flush(struct cx18_stream *s, struct cx18_queue *q)
119 buf = list_entry(q->list.next, struct cx18_buffer, list); 119 buf = list_entry(q->list.next, struct cx18_buffer, list);
120 list_move_tail(q->list.next, &s->q_free.list); 120 list_move_tail(q->list.next, &s->q_free.list);
121 buf->bytesused = buf->readpos = buf->b_flags = 0; 121 buf->bytesused = buf->readpos = buf->b_flags = 0;
122 s->q_free.buffers++; 122 atomic_inc(&s->q_free.buffers);
123 } 123 }
124 cx18_queue_init(q); 124 cx18_queue_init(q);
125 spin_unlock_irqrestore(&s->qlock, flags); 125 spin_unlock_irqrestore(&s->qlock, flags);