2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:53:56 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2006-10-18 01:47:25 -04:00
|
|
|
|
|
|
|
|
|
kfifo: move struct kfifo in place
This is a new generic kernel FIFO implementation.
The current kernel fifo API is not very widely used, because it has to
many constrains. Only 17 files in the current 2.6.31-rc5 used it.
FIFO's are like list's a very basic thing and a kfifo API which handles
the most use case would save a lot of development time and memory
resources.
I think this are the reasons why kfifo is not in use:
- The API is to simple, important functions are missing
- A fifo can be only allocated dynamically
- There is a requirement of a spinlock whether you need it or not
- There is no support for data records inside a fifo
So I decided to extend the kfifo in a more generic way without blowing up
the API to much. The new API has the following benefits:
- Generic usage: For kernel internal use and/or device driver.
- Provide an API for the most use case.
- Slim API: The whole API provides 25 functions.
- Linux style habit.
- DECLARE_KFIFO, DEFINE_KFIFO and INIT_KFIFO Macros
- Direct copy_to_user from the fifo and copy_from_user into the fifo.
- The kfifo itself is an in place member of the using data structure, this save an
indirection access and does not waste the kernel allocator.
- Lockless access: if only one reader and one writer is active on the fifo,
which is the common use case, no additional locking is necessary.
- Remove spinlock - give the user the freedom of choice what kind of locking to use if
one is required.
- Ability to handle records. Three type of records are supported:
- Variable length records between 0-255 bytes, with a record size
field of 1 bytes.
- Variable length records between 0-65535 bytes, with a record size
field of 2 bytes.
- Fixed size records, which no record size field.
- Preserve memory resource.
- Performance!
- Easy to use!
This patch:
Since most users want to have the kfifo as part of another object,
reorganize the code to allow including struct kfifo in another data
structure. This requires changing the kfifo_alloc and kfifo_init
prototypes so that we pass an existing kfifo pointer into them. This
patch changes the implementation and all existing users.
[akpm@linux-foundation.org: fix warning]
Signed-off-by: Stefani Seibold <stefani@seibold.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-21 14:37:26 -08:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2008-12-02 00:32:13 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:00 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2009-04-21 15:32:32 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:00 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-05-30 12:57:19 -05:00
|
|
|
|
2008-05-21 15:54:17 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2009-03-05 14:46:01 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:20 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-02 00:32:13 -06:00
|
|
|
|
2008-05-21 15:54:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2008-12-02 00:32:13 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-05-30 12:57:24 -05:00
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:21 -06:00
|
|
|
|
2007-12-13 12:43:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:21 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2006-07-24 15:47:15 -05:00
|
|
|
|
2009-05-13 17:57:46 -05:00
|
|
|
|
2006-07-24 15:47:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-13 17:57:49 -05:00
|
|
|
|
|
|
|
|
|
2006-07-24 15:47:15 -05:00
|
|
|
|
|
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-12-13 12:43:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
2007-12-13 12:43:23 -06:00
|
|
|
|
|
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2007-05-30 12:57:15 -05:00
|
|
|
|
2006-08-31 18:09:24 -04:00
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
2008-05-21 15:54:06 -05:00
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-15 22:11:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-24 15:47:15 -05:00
|
|
|
|
|
|
|
|
|
2006-08-31 18:09:25 -04:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
2007-12-13 12:43:23 -06:00
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
2007-12-13 12:43:23 -06:00
|
|
|
|
|
|
|
|
|
2008-01-31 13:36:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-24 15:47:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:20 -06:00
|
|
|
|
2009-05-13 17:57:46 -05:00
|
|
|
|
2007-12-13 12:43:20 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:20 -06:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2007-05-30 12:57:15 -05:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2006-06-28 12:00:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-30 12:57:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-29 13:46:52 -07:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:25 -06:00
|
|
|
|
kfifo: move struct kfifo in place
This is a new generic kernel FIFO implementation.
The current kernel fifo API is not very widely used, because it has to
many constrains. Only 17 files in the current 2.6.31-rc5 used it.
FIFO's are like list's a very basic thing and a kfifo API which handles
the most use case would save a lot of development time and memory
resources.
I think this are the reasons why kfifo is not in use:
- The API is to simple, important functions are missing
- A fifo can be only allocated dynamically
- There is a requirement of a spinlock whether you need it or not
- There is no support for data records inside a fifo
So I decided to extend the kfifo in a more generic way without blowing up
the API to much. The new API has the following benefits:
- Generic usage: For kernel internal use and/or device driver.
- Provide an API for the most use case.
- Slim API: The whole API provides 25 functions.
- Linux style habit.
- DECLARE_KFIFO, DEFINE_KFIFO and INIT_KFIFO Macros
- Direct copy_to_user from the fifo and copy_from_user into the fifo.
- The kfifo itself is an in place member of the using data structure, this save an
indirection access and does not waste the kernel allocator.
- Lockless access: if only one reader and one writer is active on the fifo,
which is the common use case, no additional locking is necessary.
- Remove spinlock - give the user the freedom of choice what kind of locking to use if
one is required.
- Ability to handle records. Three type of records are supported:
- Variable length records between 0-255 bytes, with a record size
field of 1 bytes.
- Variable length records between 0-65535 bytes, with a record size
field of 2 bytes.
- Fixed size records, which no record size field.
- Preserve memory resource.
- Performance!
- Easy to use!
This patch:
Since most users want to have the kfifo as part of another object,
reorganize the code to allow including struct kfifo in another data
structure. This requires changing the kfifo_alloc and kfifo_init
prototypes so that we pass an existing kfifo pointer into them. This
patch changes the implementation and all existing users.
[akpm@linux-foundation.org: fix warning]
Signed-off-by: Stefani Seibold <stefani@seibold.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-21 14:37:26 -08:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-31 13:36:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2008-05-21 15:53:59 -05:00
|
|
|
|
2007-08-15 01:38:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-26 12:46:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-12-13 12:43:30 -06:00
|
|
|
|
|
|
|
|
|
2009-11-11 16:34:33 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-05-30 12:57:15 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-05-30 12:57:15 -05:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:20 -06:00
|
|
|
|
2006-06-28 12:00:23 -05:00
|
|
|
|
2007-05-30 12:57:16 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-28 12:00:23 -05:00
|
|
|
|
2008-05-21 15:54:16 -05:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:06 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
2007-12-13 12:43:25 -06:00
|
|
|
|
2009-09-22 08:21:22 +05:30
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2008-09-24 11:46:10 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:53:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-09-24 11:46:10 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-05 14:46:03 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:53:59 -05:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-15 17:46:39 -07:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2010-02-20 08:02:10 +05:30
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:20 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2007-05-30 12:57:12 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:01 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-30 12:57:12 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:00 -05:00
|
|
|
|
|
|
|
|
|
2009-03-05 14:46:04 -06:00
|
|
|
|
2009-03-05 14:46:03 -06:00
|
|
|
|
2008-05-21 15:54:00 -05:00
|
|
|
|
|
|
|
|
|
2009-04-21 15:32:32 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:53:59 -05:00
|
|
|
|
2009-09-22 08:21:22 +05:30
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
2006-06-28 12:00:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2008-01-31 13:36:52 -06:00
|
|
|
|
2008-05-21 15:53:59 -05:00
|
|
|
|
2008-01-31 13:36:52 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:01 -05:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-05 14:46:05 -06:00
|
|
|
|
2008-09-24 11:46:10 -05:00
|
|
|
|
2006-06-28 12:00:23 -05:00
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:02 -05:00
|
|
|
|
2009-09-05 07:35:33 +05:30
|
|
|
|
2009-03-05 14:46:03 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2008-01-31 13:36:52 -06:00
|
|
|
|
2008-05-21 15:54:02 -05:00
|
|
|
|
|
|
|
|
|
2008-01-31 13:36:52 -06:00
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-30 12:57:18 -05:00
|
|
|
|
2008-12-02 00:32:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:18 -05:00
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:04 -05:00
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
2009-05-13 17:57:41 -05:00
|
|
|
|
2008-05-21 15:54:09 -05:00
|
|
|
|
|
|
|
|
|
2008-05-21 15:54:18 -05:00
|
|
|
|
2009-09-05 07:34:23 +05:30
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 12:43:25 -06:00
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|
2007-12-13 12:43:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-06 21:13:41 -05:00
|
|
|
|