Lines Matching full:fifo

3  * A generic kernel FIFO implementation
12 * How to porting drivers to the new generic FIFO API:
31 * and one writer is using the fifo and no kfifo_reset() will be called.
98 * helper macro to distinguish between real in place fifo where the fifo
99 * array is a part of the structure and the fifo type where the array is
100 * outside of the fifo structure.
102 #define __is_kfifo_ptr(fifo) \ argument
103 (sizeof(*fifo) == sizeof(STRUCT_KFIFO_PTR(typeof(*(fifo)->type))))
106 * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object
107 * @fifo: name of the declared fifo
108 * @type: type of the fifo elements
110 #define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo argument
113 * DECLARE_KFIFO - macro to declare a fifo object
114 * @fifo: name of the declared fifo
115 * @type: type of the fifo elements
116 * @size: the number of elements in the fifo, this must be a power of 2
118 #define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo argument
121 * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
122 * @fifo: name of the declared fifo datatype
124 #define INIT_KFIFO(fifo) \ argument
126 typeof(&(fifo)) __tmp = &(fifo); \
136 * DEFINE_KFIFO - macro to define and initialize a fifo
137 * @fifo: name of the declared fifo datatype
138 * @type: type of the fifo elements
139 * @size: the number of elements in the fifo, this must be a power of 2
141 * Note: the macro can be used for global and local fifo data type variables.
143 #define DEFINE_KFIFO(fifo, type, size) \ argument
144 DECLARE_KFIFO(fifo, type, size) = \
145 (typeof(fifo)) { \
150 .mask = __is_kfifo_ptr(&(fifo)) ? \
152 ARRAY_SIZE((fifo).buf) - 1, \
153 .esize = sizeof(*(fifo).buf), \
154 .data = __is_kfifo_ptr(&(fifo)) ? \
156 (fifo).buf, \
175 * kfifo_initialized - Check if the fifo is initialized
176 * @fifo: address of the fifo to check
178 * Return %true if fifo is initialized, otherwise %false.
179 * Assumes the fifo was 0 before.
181 #define kfifo_initialized(fifo) ((fifo)->kfifo.mask) argument
184 * kfifo_esize - returns the size of the element managed by the fifo
185 * @fifo: address of the fifo to be used
187 #define kfifo_esize(fifo) ((fifo)->kfifo.esize) argument
191 * @fifo: address of the fifo to be used
193 #define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype)) argument
196 * kfifo_size - returns the size of the fifo in elements
197 * @fifo: address of the fifo to be used
199 #define kfifo_size(fifo) ((fifo)->kfifo.mask + 1) argument
202 * kfifo_reset - removes the entire fifo content
203 * @fifo: address of the fifo to be used
206 * fifo is exclusived locked or when it is secured that no other thread is
207 * accessing the fifo.
209 #define kfifo_reset(fifo) \ argument
211 typeof((fifo) + 1) __tmp = (fifo); \
216 * kfifo_reset_out - skip fifo content
217 * @fifo: address of the fifo to be used
223 #define kfifo_reset_out(fifo) \ argument
225 typeof((fifo) + 1) __tmp = (fifo); \
230 * kfifo_len - returns the number of used elements in the fifo
231 * @fifo: address of the fifo to be used
233 #define kfifo_len(fifo) \ argument
235 typeof((fifo) + 1) __tmpl = (fifo); \
240 * kfifo_is_empty - returns true if the fifo is empty
241 * @fifo: address of the fifo to be used
243 #define kfifo_is_empty(fifo) \ argument
245 typeof((fifo) + 1) __tmpq = (fifo); \
250 * kfifo_is_full - returns true if the fifo is full
251 * @fifo: address of the fifo to be used
253 #define kfifo_is_full(fifo) \ argument
255 typeof((fifo) + 1) __tmpq = (fifo); \
260 * kfifo_avail - returns the number of unused elements in the fifo
261 * @fifo: address of the fifo to be used
263 #define kfifo_avail(fifo) \ argument
266 typeof((fifo) + 1) __tmpq = (fifo); \
277 * @fifo: address of the fifo to be used
279 #define kfifo_skip(fifo) \ argument
281 typeof((fifo) + 1) __tmp = (fifo); \
291 * kfifo_peek_len - gets the size of the next fifo record
292 * @fifo: address of the fifo to be used
294 * This function returns the size of the next fifo record in number of bytes.
296 #define kfifo_peek_len(fifo) \ argument
299 typeof((fifo) + 1) __tmp = (fifo); \
308 * kfifo_alloc - dynamically allocates a new fifo buffer
309 * @fifo: pointer to the fifo
310 * @size: the number of elements in the fifo, this must be a power of 2
313 * This macro dynamically allocates a new fifo buffer.
316 * The fifo will be release with kfifo_free().
319 #define kfifo_alloc(fifo, size, gfp_mask) \ argument
322 typeof((fifo) + 1) __tmp = (fifo); \
331 * kfifo_free - frees the fifo
332 * @fifo: the fifo to be freed
334 #define kfifo_free(fifo) \ argument
336 typeof((fifo) + 1) __tmp = (fifo); \
343 * kfifo_init - initialize a fifo using a preallocated buffer
344 * @fifo: the fifo to assign the buffer
348 * This macro initializes a fifo using a preallocated buffer.
353 #define kfifo_init(fifo, buffer, size) \ argument
355 typeof((fifo) + 1) __tmp = (fifo); \
363 * kfifo_put - put data into the fifo
364 * @fifo: address of the fifo to be used
367 * This macro copies the given value into the fifo.
368 * It returns 0 if the fifo was full. Otherwise it returns the number
374 #define kfifo_put(fifo, val) \ argument
376 typeof((fifo) + 1) __tmp = (fifo); \
400 * kfifo_get - get data from the fifo
401 * @fifo: address of the fifo to be used
404 * This macro reads the data from the fifo.
405 * It returns 0 if the fifo was empty. Otherwise it returns the number
411 #define kfifo_get(fifo, val) \ argument
414 typeof((fifo) + 1) __tmp = (fifo); \
439 * kfifo_peek - get data from the fifo without removing
440 * @fifo: address of the fifo to be used
443 * This reads the data from the fifo without removing it from the fifo.
444 * It returns 0 if the fifo was empty. Otherwise it returns the number
450 #define kfifo_peek(fifo, val) \ argument
453 typeof((fifo) + 1) __tmp = (fifo); \
477 * kfifo_in - put data into the fifo
478 * @fifo: address of the fifo to be used
482 * This macro copies the given buffer into the fifo and returns the
488 #define kfifo_in(fifo, buf, n) \ argument
490 typeof((fifo) + 1) __tmp = (fifo); \
501 * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking
502 * @fifo: address of the fifo to be used
507 * This macro copies the given values buffer into the fifo and returns the
510 #define kfifo_in_spinlocked(fifo, buf, n, lock) \ argument
515 __ret = kfifo_in(fifo, buf, n); \
521 #define kfifo_in_locked(fifo, buf, n, lock) \ argument
522 kfifo_in_spinlocked(fifo, buf, n, lock)
525 * kfifo_out - get data from the fifo
526 * @fifo: address of the fifo to be used
530 * This macro get some data from the fifo and return the numbers of elements
536 #define kfifo_out(fifo, buf, n) \ argument
539 typeof((fifo) + 1) __tmp = (fifo); \
551 * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking
552 * @fifo: address of the fifo to be used
557 * This macro get the data from the fifo and return the numbers of elements
560 #define kfifo_out_spinlocked(fifo, buf, n, lock) \ argument
566 __ret = kfifo_out(fifo, buf, n); \
573 #define kfifo_out_locked(fifo, buf, n, lock) \ argument
574 kfifo_out_spinlocked(fifo, buf, n, lock)
577 * kfifo_from_user - puts some data from user space into the fifo
578 * @fifo: address of the fifo to be used
584 * fifo, depending of the available space and returns -EFAULT/0.
589 #define kfifo_from_user(fifo, from, len, copied) \ argument
592 typeof((fifo) + 1) __tmp = (fifo); \
605 * kfifo_to_user - copies data from the fifo into user space
606 * @fifo: address of the fifo to be used
611 * This macro copies at most @len bytes from the fifo into the
617 #define kfifo_to_user(fifo, to, len, copied) \ argument
620 typeof((fifo) + 1) __tmp = (fifo); \
634 * @fifo: address of the fifo to be used
645 #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ argument
647 typeof((fifo) + 1) __tmp = (fifo); \
660 * @fifo: address of the fifo to be used
669 #define kfifo_dma_in_finish(fifo, len) \ argument
671 typeof((fifo) + 1) __tmp = (fifo); \
683 * @fifo: address of the fifo to be used
696 #define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ argument
698 typeof((fifo) + 1) __tmp = (fifo); \
711 * @fifo: address of the fifo to be used
720 #define kfifo_dma_out_finish(fifo, len) \ argument
722 typeof((fifo) + 1) __tmp = (fifo); \
733 * kfifo_out_peek - gets some data from the fifo
734 * @fifo: address of the fifo to be used
738 * This macro get the data from the fifo and return the numbers of elements
739 * copied. The data is not removed from the fifo.
744 #define kfifo_out_peek(fifo, buf, n) \ argument
747 typeof((fifo) + 1) __tmp = (fifo); \
758 extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
761 extern void __kfifo_free(struct __kfifo *fifo);
763 extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
766 extern unsigned int __kfifo_in(struct __kfifo *fifo,
769 extern unsigned int __kfifo_out(struct __kfifo *fifo,
772 extern int __kfifo_from_user(struct __kfifo *fifo,
775 extern int __kfifo_to_user(struct __kfifo *fifo,
778 extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
781 extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
784 extern unsigned int __kfifo_out_peek(struct __kfifo *fifo,
787 extern unsigned int __kfifo_in_r(struct __kfifo *fifo,
790 extern unsigned int __kfifo_out_r(struct __kfifo *fifo,
793 extern int __kfifo_from_user_r(struct __kfifo *fifo,
797 extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
800 extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
803 extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
806 extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
809 extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize);
811 extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize);
813 extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize);
815 extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo,