Lines Matching +full:read +full:- +full:1

2  * Copyright (c) 2010-2012 Broadcom. All rights reserved.
7 * 1. Redistributions of source code must retain the above copyright
13 * 3. The names of the above-listed copyright holders may not be used
38 return i && !(i & (i - 1)); in is_pow2()
45 queue->size = size; in vchiu_queue_init()
46 queue->read = 0; in vchiu_queue_init()
47 queue->write = 0; in vchiu_queue_init()
48 queue->initialized = 1; in vchiu_queue_init()
50 _sema_init(&queue->pop, 0); in vchiu_queue_init()
51 _sema_init(&queue->push, 0); in vchiu_queue_init()
53 queue->storage = kzalloc(size * sizeof(VCHIQ_HEADER_T *), GFP_KERNEL); in vchiu_queue_init()
54 if (queue->storage == NULL) { in vchiu_queue_init()
58 return 1; in vchiu_queue_init()
63 if (queue->storage != NULL) in vchiu_queue_delete()
64 kfree(queue->storage); in vchiu_queue_delete()
69 return queue->read == queue->write; in vchiu_queue_is_empty()
74 return queue->write == queue->read + queue->size; in vchiu_queue_is_full()
79 if (!queue->initialized) in vchiu_queue_push()
82 while (queue->write == queue->read + queue->size) { in vchiu_queue_push()
83 if (down_interruptible(&queue->pop) != 0) { in vchiu_queue_push()
89 * Write to queue->storage must be visible after read from in vchiu_queue_push()
90 * queue->read in vchiu_queue_push()
94 queue->storage[queue->write & (queue->size - 1)] = header; in vchiu_queue_push()
97 * Write to queue->storage must be visible before write to in vchiu_queue_push()
98 * queue->write in vchiu_queue_push()
102 queue->write++; in vchiu_queue_push()
104 up(&queue->push); in vchiu_queue_push()
109 while (queue->write == queue->read) { in vchiu_queue_peek()
110 if (down_interruptible(&queue->push) != 0) { in vchiu_queue_peek()
115 up(&queue->push); // We haven't removed anything from the queue. in vchiu_queue_peek()
118 * Read from queue->storage must be visible after read from in vchiu_queue_peek()
119 * queue->write in vchiu_queue_peek()
123 return queue->storage[queue->read & (queue->size - 1)]; in vchiu_queue_peek()
130 while (queue->write == queue->read) { in vchiu_queue_pop()
131 if (down_interruptible(&queue->push) != 0) { in vchiu_queue_pop()
137 * Read from queue->storage must be visible after read from in vchiu_queue_pop()
138 * queue->write in vchiu_queue_pop()
142 header = queue->storage[queue->read & (queue->size - 1)]; in vchiu_queue_pop()
145 * Read from queue->storage must be visible before write to in vchiu_queue_pop()
146 * queue->read in vchiu_queue_pop()
150 queue->read++; in vchiu_queue_pop()
152 up(&queue->pop); in vchiu_queue_pop()