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_empty_spinlocked - returns true if the fifo is empty using
252 * @fifo: address of the fifo to be used
255 #define kfifo_is_empty_spinlocked(fifo, lock) \ argument
260 __ret = kfifo_is_empty(fifo); \
266 * kfifo_is_empty_spinlocked_noirqsave - returns true if the fifo is empty
268 * @fifo: address of the fifo to be used
271 #define kfifo_is_empty_spinlocked_noirqsave(fifo, lock) \ argument
275 __ret = kfifo_is_empty(fifo); \
281 * kfifo_is_full - returns true if the fifo is full
282 * @fifo: address of the fifo to be used
284 #define kfifo_is_full(fifo) \ argument
286 typeof((fifo) + 1) __tmpq = (fifo); \
291 * kfifo_avail - returns the number of unused elements in the fifo
292 * @fifo: address of the fifo to be used
294 #define kfifo_avail(fifo) \ argument
297 typeof((fifo) + 1) __tmpq = (fifo); \
308 * @fifo: address of the fifo to be used
310 #define kfifo_skip(fifo) \ argument
312 typeof((fifo) + 1) __tmp = (fifo); \
322 * kfifo_peek_len - gets the size of the next fifo record
323 * @fifo: address of the fifo to be used
325 * This function returns the size of the next fifo record in number of bytes.
327 #define kfifo_peek_len(fifo) \ argument
330 typeof((fifo) + 1) __tmp = (fifo); \
339 * kfifo_alloc - dynamically allocates a new fifo buffer
340 * @fifo: pointer to the fifo
341 * @size: the number of elements in the fifo, this must be a power of 2
344 * This macro dynamically allocates a new fifo buffer.
347 * The fifo will be release with kfifo_free().
350 #define kfifo_alloc(fifo, size, gfp_mask) \ argument
353 typeof((fifo) + 1) __tmp = (fifo); \
362 * kfifo_free - frees the fifo
363 * @fifo: the fifo to be freed
365 #define kfifo_free(fifo) \ argument
367 typeof((fifo) + 1) __tmp = (fifo); \
374 * kfifo_init - initialize a fifo using a preallocated buffer
375 * @fifo: the fifo to assign the buffer
379 * This macro initializes a fifo using a preallocated buffer.
384 #define kfifo_init(fifo, buffer, size) \ argument
386 typeof((fifo) + 1) __tmp = (fifo); \
394 * kfifo_put - put data into the fifo
395 * @fifo: address of the fifo to be used
398 * This macro copies the given value into the fifo.
399 * It returns 0 if the fifo was full. Otherwise it returns the number
405 #define kfifo_put(fifo, val) \ argument
407 typeof((fifo) + 1) __tmp = (fifo); \
431 * kfifo_get - get data from the fifo
432 * @fifo: address of the fifo to be used
435 * This macro reads the data from the fifo.
436 * It returns 0 if the fifo was empty. Otherwise it returns the number
442 #define kfifo_get(fifo, val) \ argument
445 typeof((fifo) + 1) __tmp = (fifo); \
470 * kfifo_peek - get data from the fifo without removing
471 * @fifo: address of the fifo to be used
474 * This reads the data from the fifo without removing it from the fifo.
475 * It returns 0 if the fifo was empty. Otherwise it returns the number
481 #define kfifo_peek(fifo, val) \ argument
484 typeof((fifo) + 1) __tmp = (fifo); \
508 * kfifo_in - put data into the fifo
509 * @fifo: address of the fifo to be used
513 * This macro copies the given buffer into the fifo and returns the
519 #define kfifo_in(fifo, buf, n) \ argument
521 typeof((fifo) + 1) __tmp = (fifo); \
532 * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking
533 * @fifo: address of the fifo to be used
538 * This macro copies the given values buffer into the fifo and returns the
541 #define kfifo_in_spinlocked(fifo, buf, n, lock) \ argument
546 __ret = kfifo_in(fifo, buf, n); \
552 * kfifo_in_spinlocked_noirqsave - put data into fifo using a spinlock for
554 * @fifo: address of the fifo to be used
562 #define kfifo_in_spinlocked_noirqsave(fifo, buf, n, lock) \ argument
566 __ret = kfifo_in(fifo, buf, n); \
572 #define kfifo_in_locked(fifo, buf, n, lock) \ argument
573 kfifo_in_spinlocked(fifo, buf, n, lock)
576 * kfifo_out - get data from the fifo
577 * @fifo: address of the fifo to be used
581 * This macro get some data from the fifo and return the numbers of elements
587 #define kfifo_out(fifo, buf, n) \ argument
590 typeof((fifo) + 1) __tmp = (fifo); \
602 * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking
603 * @fifo: address of the fifo to be used
608 * This macro get the data from the fifo and return the numbers of elements
611 #define kfifo_out_spinlocked(fifo, buf, n, lock) \ argument
617 __ret = kfifo_out(fifo, buf, n); \
624 * kfifo_out_spinlocked_noirqsave - get data from the fifo using a spinlock
626 * @fifo: address of the fifo to be used
634 #define kfifo_out_spinlocked_noirqsave(fifo, buf, n, lock) \ argument
639 __ret = kfifo_out(fifo, buf, n); \
646 #define kfifo_out_locked(fifo, buf, n, lock) \ argument
647 kfifo_out_spinlocked(fifo, buf, n, lock)
650 * kfifo_from_user - puts some data from user space into the fifo
651 * @fifo: address of the fifo to be used
657 * fifo, depending of the available space and returns -EFAULT/0.
662 #define kfifo_from_user(fifo, from, len, copied) \ argument
665 typeof((fifo) + 1) __tmp = (fifo); \
678 * kfifo_to_user - copies data from the fifo into user space
679 * @fifo: address of the fifo to be used
684 * This macro copies at most @len bytes from the fifo into the
690 #define kfifo_to_user(fifo, to, len, copied) \ argument
693 typeof((fifo) + 1) __tmp = (fifo); \
707 * @fifo: address of the fifo to be used
718 #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ argument
720 typeof((fifo) + 1) __tmp = (fifo); \
733 * @fifo: address of the fifo to be used
742 #define kfifo_dma_in_finish(fifo, len) \ argument
744 typeof((fifo) + 1) __tmp = (fifo); \
756 * @fifo: address of the fifo to be used
769 #define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ argument
771 typeof((fifo) + 1) __tmp = (fifo); \
784 * @fifo: address of the fifo to be used
793 #define kfifo_dma_out_finish(fifo, len) \ argument
795 typeof((fifo) + 1) __tmp = (fifo); \
806 * kfifo_out_peek - gets some data from the fifo
807 * @fifo: address of the fifo to be used
811 * This macro get the data from the fifo and return the numbers of elements
812 * copied. The data is not removed from the fifo.
817 #define kfifo_out_peek(fifo, buf, n) \ argument
820 typeof((fifo) + 1) __tmp = (fifo); \
831 extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
834 extern void __kfifo_free(struct __kfifo *fifo);
836 extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
839 extern unsigned int __kfifo_in(struct __kfifo *fifo,
842 extern unsigned int __kfifo_out(struct __kfifo *fifo,
845 extern int __kfifo_from_user(struct __kfifo *fifo,
848 extern int __kfifo_to_user(struct __kfifo *fifo,
851 extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
854 extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
857 extern unsigned int __kfifo_out_peek(struct __kfifo *fifo,
860 extern unsigned int __kfifo_in_r(struct __kfifo *fifo,
863 extern unsigned int __kfifo_out_r(struct __kfifo *fifo,
866 extern int __kfifo_from_user_r(struct __kfifo *fifo,
870 extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
873 extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
876 extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
879 extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
882 extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize);
884 extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize);
886 extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize);
888 extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo,