linux/drivers/platform/x86
Stefani Seibold 4546548789 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-22 14:17:55 -08:00
..
Kconfig Merge branch 'toshiba-bt' into release 2009-12-16 13:57:16 -05:00
Makefile Merge branch 'toshiba-bt' into release 2009-12-16 13:57:16 -05:00
acer-wmi.c Input: libps2 - additional locking for i8042 ports 2009-09-17 23:23:45 -07:00
acerhdf.c Merge branch 'misc-2.6.33' into release 2009-12-16 14:22:32 -05:00
asus-laptop.c asus-laptop: change light sens default values. 2009-12-15 20:01:36 -05:00
asus_acpi.c asus-acpi: set acpi_driver.owner 2009-12-09 15:54:30 -05:00
compal-laptop.c drop explicit include of autoconf.h 2009-12-12 13:08:15 +01:00
dell-laptop.c dell-laptop: add __init to init functions 2009-12-10 00:02:31 -05:00
dell-wmi.c dell-wmi: Add support for new Dell systems 2009-12-10 00:19:36 -05:00
eeepc-laptop.c Merge branch 'asus' into release 2009-12-15 22:34:48 -05:00
fujitsu-laptop.c kfifo: move struct kfifo in place 2009-12-22 14:17:55 -08:00
hp-wmi.c Merge branch 'hp-wmi' into release 2009-12-15 22:35:40 -05:00
intel_menlow.c ACPICA: Add post-order callback to acpi_walk_namespace 2009-11-24 21:31:10 -05:00
msi-laptop.c
msi-wmi.c msi-wmi: depend on backlight and fix corner-cases problems 2009-12-16 12:40:54 -05:00
panasonic-laptop.c Merge branches 'release', 'APERF', 'ARAT', 'misc', 'kelvin', 'device-lock' and 'bjorn.notify' into release 2009-04-07 18:18:42 -04:00
sony-laptop.c kfifo: move struct kfifo in place 2009-12-22 14:17:55 -08:00
tc1100-wmi.c tc1100-wmi: Fix state reporting 2009-04-03 12:03:27 -04:00
thinkpad_acpi.c Merge branch 'thinkpad-2.6.33' into release 2009-12-16 00:00:54 -05:00
topstar-laptop.c topstar-laptop: add new driver for hotkeys support on Topstar N01 2009-09-19 01:16:13 -04:00
toshiba_acpi.c toshiba_acpi: return on a fail path 2009-08-28 15:17:07 -04:00
toshiba_bluetooth.c Toshiba Bluetooth Enabling driver (RFKill handler v3) 2009-12-16 12:09:46 -05:00
wmi.c wmi: Add support for module autoloading 2009-11-05 12:29:37 -05:00