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.
103 * helper macro to distinguish between real in place fifo where the fifo
104 * array is a part of the structure and the fifo type where the array is
105 * outside of the fifo structure.
107 #define __is_kfifo_ptr(fifo) \ argument
108 (sizeof(*fifo) == sizeof(STRUCT_KFIFO_PTR(typeof(*(fifo)->type))))
111 * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object
112 * @fifo: name of the declared fifo
113 * @type: type of the fifo elements
115 #define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo argument
118 * DECLARE_KFIFO - macro to declare a fifo object
119 * @fifo: name of the declared fifo
120 * @type: type of the fifo elements
121 * @size: the number of elements in the fifo, this must be a power of 2
123 #define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo argument
126 * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
127 * @fifo: name of the declared fifo datatype
129 #define INIT_KFIFO(fifo) \ argument
131 typeof(&(fifo)) __tmp = &(fifo); \
141 * DEFINE_KFIFO - macro to define and initialize a fifo
142 * @fifo: name of the declared fifo datatype
143 * @type: type of the fifo elements
144 * @size: the number of elements in the fifo, this must be a power of 2
146 * Note: the macro can be used for global and local fifo data type variables.
148 #define DEFINE_KFIFO(fifo, type, size) \ argument
149 DECLARE_KFIFO(fifo, type, size) = \
150 (typeof(fifo)) { \
155 .mask = __is_kfifo_ptr(&(fifo)) ? \
157 ARRAY_SIZE((fifo).buf) - 1, \
158 .esize = sizeof(*(fifo).buf), \
159 .data = __is_kfifo_ptr(&(fifo)) ? \
161 (fifo).buf, \
180 * kfifo_initialized - Check if the fifo is initialized
181 * @fifo: address of the fifo to check
183 * Return %true if fifo is initialized, otherwise %false.
184 * Assumes the fifo was 0 before.
186 #define kfifo_initialized(fifo) ((fifo)->kfifo.mask) argument
189 * kfifo_esize - returns the size of the element managed by the fifo
190 * @fifo: address of the fifo to be used
192 #define kfifo_esize(fifo) ((fifo)->kfifo.esize) argument
196 * @fifo: address of the fifo to be used
198 #define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype)) argument
201 * kfifo_size - returns the size of the fifo in elements
202 * @fifo: address of the fifo to be used
204 #define kfifo_size(fifo) ((fifo)->kfifo.mask + 1) argument
207 * kfifo_reset - removes the entire fifo content
208 * @fifo: address of the fifo to be used
211 * fifo is exclusived locked or when it is secured that no other thread is
212 * accessing the fifo.
214 #define kfifo_reset(fifo) \ argument
216 typeof((fifo) + 1) __tmp = (fifo); \
221 * kfifo_reset_out - skip fifo content
222 * @fifo: address of the fifo to be used
228 #define kfifo_reset_out(fifo) \ argument
230 typeof((fifo) + 1) __tmp = (fifo); \
235 * kfifo_len - returns the number of used elements in the fifo
236 * @fifo: address of the fifo to be used
238 #define kfifo_len(fifo) \ argument
240 typeof((fifo) + 1) __tmpl = (fifo); \
245 * kfifo_is_empty - returns true if the fifo is empty
246 * @fifo: address of the fifo to be used
248 #define kfifo_is_empty(fifo) \ argument
250 typeof((fifo) + 1) __tmpq = (fifo); \
255 * kfifo_is_empty_spinlocked - returns true if the fifo is empty using
257 * @fifo: address of the fifo to be used
260 #define kfifo_is_empty_spinlocked(fifo, lock) \ argument
265 __ret = kfifo_is_empty(fifo); \
271 * kfifo_is_empty_spinlocked_noirqsave - returns true if the fifo is empty
273 * @fifo: address of the fifo to be used
276 #define kfifo_is_empty_spinlocked_noirqsave(fifo, lock) \ argument
280 __ret = kfifo_is_empty(fifo); \
286 * kfifo_is_full - returns true if the fifo is full
287 * @fifo: address of the fifo to be used
289 #define kfifo_is_full(fifo) \ argument
291 typeof((fifo) + 1) __tmpq = (fifo); \
296 * kfifo_avail - returns the number of unused elements in the fifo
297 * @fifo: address of the fifo to be used
299 #define kfifo_avail(fifo) \ argument
302 typeof((fifo) + 1) __tmpq = (fifo); \
313 * @fifo: address of the fifo to be used
316 #define kfifo_skip_count(fifo, count) do { \ argument
317 typeof((fifo) + 1) __tmp = (fifo); \
328 * @fifo: address of the fifo to be used
330 #define kfifo_skip(fifo) kfifo_skip_count(fifo, 1) argument
333 * kfifo_peek_len - gets the size of the next fifo record
334 * @fifo: address of the fifo to be used
336 * This function returns the size of the next fifo record in number of bytes.
338 #define kfifo_peek_len(fifo) \ argument
341 typeof((fifo) + 1) __tmp = (fifo); \
350 * kfifo_alloc - dynamically allocates a new fifo buffer
351 * @fifo: pointer to the fifo
352 * @size: the number of elements in the fifo, this must be a power of 2
355 * This macro dynamically allocates a new fifo buffer.
358 * The fifo will be release with kfifo_free().
361 #define kfifo_alloc(fifo, size, gfp_mask) \ argument
364 typeof((fifo) + 1) __tmp = (fifo); \
373 * kfifo_free - frees the fifo
374 * @fifo: the fifo to be freed
376 #define kfifo_free(fifo) \ argument
378 typeof((fifo) + 1) __tmp = (fifo); \
385 * kfifo_init - initialize a fifo using a preallocated buffer
386 * @fifo: the fifo to assign the buffer
390 * This macro initializes a fifo using a preallocated buffer.
395 #define kfifo_init(fifo, buffer, size) \ argument
397 typeof((fifo) + 1) __tmp = (fifo); \
405 * kfifo_put - put data into the fifo
406 * @fifo: address of the fifo to be used
409 * This macro copies the given value into the fifo.
410 * It returns 0 if the fifo was full. Otherwise it returns the number
416 #define kfifo_put(fifo, val) \ argument
418 typeof((fifo) + 1) __tmp = (fifo); \
442 * kfifo_get - get data from the fifo
443 * @fifo: address of the fifo to be used
446 * This macro reads the data from the fifo.
447 * It returns 0 if the fifo was empty. Otherwise it returns the number
453 #define kfifo_get(fifo, val) \ argument
456 typeof((fifo) + 1) __tmp = (fifo); \
481 * kfifo_peek - get data from the fifo without removing
482 * @fifo: address of the fifo to be used
485 * This reads the data from the fifo without removing it from the fifo.
486 * It returns 0 if the fifo was empty. Otherwise it returns the number
492 #define kfifo_peek(fifo, val) \ argument
495 typeof((fifo) + 1) __tmp = (fifo); \
519 * kfifo_in - put data into the fifo
520 * @fifo: address of the fifo to be used
524 * This macro copies the given buffer into the fifo and returns the
530 #define kfifo_in(fifo, buf, n) \ argument
532 typeof((fifo) + 1) __tmp = (fifo); \
543 * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking
544 * @fifo: address of the fifo to be used
549 * This macro copies the given values buffer into the fifo and returns the
552 #define kfifo_in_spinlocked(fifo, buf, n, lock) \ argument
557 __ret = kfifo_in(fifo, buf, n); \
563 * kfifo_in_spinlocked_noirqsave - put data into fifo using a spinlock for
565 * @fifo: address of the fifo to be used
573 #define kfifo_in_spinlocked_noirqsave(fifo, buf, n, lock) \ argument
577 __ret = kfifo_in(fifo, buf, n); \
583 #define kfifo_in_locked(fifo, buf, n, lock) \ argument
584 kfifo_in_spinlocked(fifo, buf, n, lock)
587 * kfifo_out - get data from the fifo
588 * @fifo: address of the fifo to be used
592 * This macro gets some data from the fifo and returns the numbers of elements
598 #define kfifo_out(fifo, buf, n) \ argument
601 typeof((fifo) + 1) __tmp = (fifo); \
613 * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking
614 * @fifo: address of the fifo to be used
619 * This macro gets the data from the fifo and returns the numbers of elements
622 #define kfifo_out_spinlocked(fifo, buf, n, lock) \ argument
628 __ret = kfifo_out(fifo, buf, n); \
635 * kfifo_out_spinlocked_noirqsave - get data from the fifo using a spinlock
637 * @fifo: address of the fifo to be used
645 #define kfifo_out_spinlocked_noirqsave(fifo, buf, n, lock) \ argument
650 __ret = kfifo_out(fifo, buf, n); \
657 #define kfifo_out_locked(fifo, buf, n, lock) \ argument
658 kfifo_out_spinlocked(fifo, buf, n, lock)
661 * kfifo_from_user - puts some data from user space into the fifo
662 * @fifo: address of the fifo to be used
668 * fifo, depending of the available space and returns -EFAULT/0.
673 #define kfifo_from_user(fifo, from, len, copied) \ argument
676 typeof((fifo) + 1) __tmp = (fifo); \
689 * kfifo_to_user - copies data from the fifo into user space
690 * @fifo: address of the fifo to be used
695 * This macro copies at most @len bytes from the fifo into the
701 #define kfifo_to_user(fifo, to, len, copied) \ argument
704 typeof((fifo) + 1) __tmp = (fifo); \
718 * @fifo: address of the fifo to be used
730 #define kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len, dma) \ argument
732 typeof((fifo) + 1) __tmp = (fifo); \
744 #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ argument
745 kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len, DMA_MAPPING_ERROR)
749 * @fifo: address of the fifo to be used
758 #define kfifo_dma_in_finish(fifo, len) \ argument
760 typeof((fifo) + 1) __tmp = (fifo); \
772 * @fifo: address of the fifo to be used
786 #define kfifo_dma_out_prepare_mapped(fifo, sgl, nents, len, dma) \ argument
788 typeof((fifo) + 1) __tmp = (fifo); \
800 #define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ argument
801 kfifo_dma_out_prepare_mapped(fifo, sgl, nents, len, DMA_MAPPING_ERROR)
805 * @fifo: address of the fifo to be used
814 #define kfifo_dma_out_finish(fifo, len) do { \ argument
815 typeof((fifo) + 1) ___tmp = (fifo); \
820 * kfifo_out_peek - gets some data from the fifo
821 * @fifo: address of the fifo to be used
825 * This macro gets the data from the fifo and returns the numbers of elements
826 * copied. The data is not removed from the fifo.
831 #define kfifo_out_peek(fifo, buf, n) \ argument
834 typeof((fifo) + 1) __tmp = (fifo); \
847 * @fifo: address of the fifo to be used
851 * This macro obtains the offset (tail) to the available data in the fifo
855 * data processing (like memcpy() of (@fifo->data + @tail) with count
861 #define kfifo_out_linear(fifo, tail, n) \ argument
864 typeof((fifo) + 1) __tmp = (fifo); \
877 * @fifo: address of the fifo to be used
882 * available data in the fifo buffer and returns the numbers of elements
890 #define kfifo_out_linear_ptr(fifo, ptr, n) \ argument
893 typeof((fifo) + 1) ___tmp = (fifo); \
902 extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
905 extern void __kfifo_free(struct __kfifo *fifo);
907 extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
910 extern unsigned int __kfifo_in(struct __kfifo *fifo,
913 extern unsigned int __kfifo_out(struct __kfifo *fifo,
916 extern int __kfifo_from_user(struct __kfifo *fifo,
919 extern int __kfifo_to_user(struct __kfifo *fifo,
922 extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
925 extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
928 extern unsigned int __kfifo_out_peek(struct __kfifo *fifo,
931 extern unsigned int __kfifo_out_linear(struct __kfifo *fifo,
934 extern unsigned int __kfifo_in_r(struct __kfifo *fifo,
937 extern unsigned int __kfifo_out_r(struct __kfifo *fifo,
940 extern int __kfifo_from_user_r(struct __kfifo *fifo,
944 extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
947 extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
951 extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
954 extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
958 extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize);
960 extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize);
962 extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo,
965 extern unsigned int __kfifo_out_linear_r(struct __kfifo *fifo,