summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2010-08-10 18:03:37 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-11 08:59:23 -0700
commit4457d9845927b3c62b6e833be243d21d6ca7df47 (patch)
treec18beec72aa318227225b22ea323c45760439e32 /drivers/char
parentad9c7ed0685406fe3cd7f0749b82bf433a39dd9c (diff)
downloadblackbird-op-linux-4457d9845927b3c62b6e833be243d21d6ca7df47.tar.gz
blackbird-op-linux-4457d9845927b3c62b6e833be243d21d6ca7df47.zip
kfifo: fix kfifo miss use of nozami.c
There are different types of a fifo which can not handled in C without a lot of overhead. So i decided to write the API as a set of macros, which is the only way to do a kind of template meta programming without C++. This macros handles the different types of fifos in a transparent way. There are a lot of benefits: - Compile time handling of the different fifo types - Better performance (a save put or get of an integer does only generate 9 assembly instructions on a x86) - Type save - Cleaner interface, the additional kfifo_..._rec() functions are gone - Easier to use - Less error prone - Different types of fifos: it is now possible to define a int fifo or any other type. See below for an example. - Smaller footprint for none byte type fifos - No need of creating a second hidden variable, like in the old DEFINE_KFIFO The API was not changed. There are now real in place fifos where the data space is a part of the structure. The fifo needs now 20 byte plus the fifo space. Dynamic assigned or allocated create a little bit more code. Most of the macros code will be optimized away and simple generate a function call. Only the really small one generates inline code. Additionally you can now create fifos for any data type, not only the "unsigned char" byte streamed fifos. There is also a new kfifo_put and kfifo_get function, to handle a single element in a fifo. This macros generates inline code, which is lit bit larger but faster. I know that this kind of macros are very sophisticated and not easy to maintain. But i have all tested and it works as expected. I analyzed the output of the compiler and for the x86 the code is as good as hand written assembler code. For the byte stream fifo the generate code is exact the same as with the current kfifo implementation. For all other types of fifos the code is smaller before, because the interface is easier to use. The main goal was to provide an API which is very intuitive, save and easy to use. So linux will get now a powerful fifo API which provides all what a developer needs. This will save in the future a lot of kernel space, since there is no need to write an own implementation. Most of the device driver developers need a fifo, and also deep kernel development will gain benefit from this API. Here are the results of the text section usage: Example 1: kfifo_put/_get kfifo_in/out current kfifo dynamic allocated 0x000002a8 0x00000291 0x00000299 in place 0x00000291 0x0000026e 0x00000273 kfifo.c new old text section size 0x00000be5 0x000008b2 As you can see, kfifo_put/kfifo_get creates a little bit more code than kfifo_in/kfifo_out, but it is much faster (the code is inline). The code is complete hand crafted and optimized. The text section size is as small as possible. You get all the fifo handling in only 3 kb. This includes type safe fix size records, dynamic records and DMA handling. This should be the final version. All requested features are implemented. Note: Most features of this API doesn't have any users. All functions which are not used in the next 9 months will be removed. So, please adapt your drivers and other sources as soon as possible to the new API and post it. This are the features which are currently not used in the kernel: kfifo_to_user() kfifo_from_user() kfifo_dma_....() macros kfifo_esize() kfifo_recsize() kfifo_put() kfifo_get() The fixed size record elements, exclude "unsigned char" fifo's and the variable size records fifo's This patch: User of the kernel fifo should never bypass the API and directly access the fifo structure. Otherwise it will be very hard to maintain the API. Signed-off-by: Stefani Seibold <stefani@seibold.net> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/nozomi.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 18af923093c3..817169cbb245 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -1743,8 +1743,7 @@ static int ntty_write_room(struct tty_struct *tty)
if (dc) {
mutex_lock(&port->tty_sem);
if (port->port.count)
- room = port->fifo_ul.size -
- kfifo_len(&port->fifo_ul);
+ room = kfifo_avail(&port->fifo_ul);
mutex_unlock(&port->tty_sem);
}
return room;
OpenPOWER on IntegriCloud