X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=include%2Flinux%2Fkfifo.h;h=9fad0527344fb1203bd8bdace4a77fc9045301b4;hb=HEAD;hp=7ad6d32dd673d19b1a789bab112d81b5fdce7a3f;hpb=a5b9e2c1063046421ce01dcf5ddd7ec12567f3e1;p=safe%2Fjmp%2Flinux-2.6 diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h index 7ad6d32..9fad052 100644 --- a/include/linux/kfifo.h +++ b/include/linux/kfifo.h @@ -67,7 +67,7 @@ struct kfifo { /** * DECLARE_KFIFO - macro to declare a kfifo and the associated buffer * @name: name of the declared kfifo datatype - * @size: size of the fifo buffer + * @size: size of the fifo buffer. Must be a power of two. * * Note1: the macro can be used inside struct or union declaration * Note2: the macro creates two objects: @@ -86,12 +86,13 @@ union { \ */ #define INIT_KFIFO(name) \ name = __kfifo_initializer(sizeof(name##kfifo_buffer) - \ - sizeof(struct kfifo), name##kfifo_buffer) + sizeof(struct kfifo), \ + name##kfifo_buffer + sizeof(struct kfifo)) /** * DEFINE_KFIFO - macro to define and initialize a kfifo * @name: name of the declared kfifo datatype - * @size: size of the fifo buffer + * @size: size of the fifo buffer. Must be a power of two. * * Note1: the macro can be used for global and local kfifo data type variables * Note2: the macro creates two objects: @@ -102,8 +103,6 @@ union { \ unsigned char name##kfifo_buffer[size]; \ struct kfifo name = __kfifo_initializer(size, name##kfifo_buffer) -#undef __kfifo_initializer - extern void kfifo_init(struct kfifo *fifo, void *buffer, unsigned int size); extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size, @@ -116,6 +115,16 @@ extern __must_check unsigned int kfifo_out(struct kfifo *fifo, extern __must_check unsigned int kfifo_out_peek(struct kfifo *fifo, void *to, unsigned int len, unsigned offset); +/** + * kfifo_initialized - Check if kfifo is initialized. + * @fifo: fifo to check + * Return %true if FIFO is initialized, otherwise %false. + * Assumes the fifo was 0 before. + */ +static inline bool kfifo_initialized(struct kfifo *fifo) +{ + return fifo->buffer != NULL; +} /** * kfifo_reset - removes the entire FIFO contents @@ -192,7 +201,7 @@ static inline __must_check unsigned int kfifo_avail(struct kfifo *fifo) * @n: the length of the data to be added. * @lock: pointer to the spinlock to use for locking. * - * This function copies at most @len bytes from the @from buffer into + * This function copies at most @n bytes from the @from buffer into * the FIFO depending on the free space, and returns the number of * bytes copied. */ @@ -218,7 +227,7 @@ static inline unsigned int kfifo_in_locked(struct kfifo *fifo, * @n: the size of the destination buffer. * @lock: pointer to the spinlock to use for locking. * - * This function copies at most @len bytes from the FIFO into the + * This function copies at most @n bytes from the FIFO into the * @to buffer and returns the number of copied bytes. */ static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,