28 Oct, 2010

1 commit

  • Add a new __kfifo_int_must_check_helper() helper function, which is needed
    for kfifo_alloc() to return the right signed integer value.

    The origin __kfifo_must_check_helper() helper was renamed into
    __kfifo_uint_must_check_helper() to show the sign which is expected and
    returned.

    (And revert the temporary disabling of __kfifo_must_check_helper())

    Signed-off-by: Stefani Seibold
    Acked-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     

27 Oct, 2010

1 commit

  • This helper is wrong: it coerces signed values into unsigned ones, so code
    such as

    if (kfifo_alloc(...) < 0) {
    error
    }

    will fail to detect the error.

    So let's disable __kfifo_must_check_helper() for 2.6.36.

    Cc: Randy Dunlap
    Cc: Stefani Seibold
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

10 Sep, 2010

1 commit


21 Aug, 2010

1 commit


11 Aug, 2010

2 commits


23 Apr, 2010

1 commit


07 Apr, 2010

1 commit

  • DECLARE_KFIFO creates a union with a struct kfifo and a buffer array with
    size [size + sizeof(struct kfifo)].

    INIT_KFIFO then sets the buffer pointer in struct kfifo to point to the
    beginning of the buffer array which means that the first call to kfifo_in
    will overwrite members of the struct kfifo.

    Signed-off-by: David Härdeman
    Acked-by: Stefani Seibold
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Härdeman
     

25 Mar, 2010

1 commit

  • include/linux/kfifo.h first defines and then undefines __kfifo_initializer
    which is used by INIT_KFIFO (which is also a macro, so building a module
    which uses INIT_KFIFO will fail).

    Signed-off-by: David Härdeman
    Acked-by: Stefani Seibold
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Härdeman
     

18 Mar, 2010

1 commit


17 Feb, 2010

1 commit

  • This patch fixes following sparse warnings:

    include/linux/kfifo.h:127:25: warning: Using plain integer as NULL pointer
    kernel/kfifo.c:83:21: warning: Using plain integer as NULL pointer

    Signed-off-by: Anton Vorontsov
    Acked-by: Stefani Seibold
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     

17 Jan, 2010

6 commits

  • On my first try using them I missed that the fifos need to be power of
    two, resulting in a runtime bug. Document that requirement everywhere
    (and fix one grammar bug)

    Signed-off-by: Andi Kleen
    Acked-by: Stefani Seibold
    Cc: Roland Dreier
    Cc: Dmitry Torokhov
    Cc: Andy Walls
    Cc: Vikram Dhillon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     
  • Simple inline that checks if kfifo_init() has been executed on a fifo.

    This is useful for walking all per CPU fifos, when some of them might not
    have been brought up yet.

    Signed-off-by: Andi Kleen
    Acked-by: Stefani Seibold
    Cc: Roland Dreier
    Cc: Dmitry Torokhov
    Cc: Andy Walls
    Cc: Vikram Dhillon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     
  • In some upcoming code it's useful to peek into a FIFO without permanentely
    removing data. This patch implements a new kfifo_out_peek() to do this.

    Signed-off-by: Andi Kleen
    Acked-by: Stefani Seibold
    Cc: Roland Dreier
    Cc: Dmitry Torokhov
    Cc: Andy Walls
    Cc: Vikram Dhillon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     
  • Right now for kfifo_*_user it's not easily possible to distingush between
    a user copy failing and the FIFO not containing enough data. The problem
    is that both conditions are multiplexed into the same return code.

    Avoid this by moving the "copy length" into a separate output parameter
    and only return 0/-EFAULT in the main return value.

    I didn't fully adapt the weird "record" variants, those seem
    to be unused anyways and were rather messy (should they be just removed?)

    I would appreciate some double checking if I did all the conversions
    correctly.

    Signed-off-by: Andi Kleen
    Cc: Stefani Seibold
    Cc: Roland Dreier
    Cc: Dmitry Torokhov
    Cc: Andy Walls
    Cc: Vikram Dhillon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     
  • The pointers to user buffers are currently unsigned char *, which requires
    a lot of casting in the caller for any non-char typed buffers. Use void *
    instead.

    Signed-off-by: Andi Kleen
    Acked-by: Stefani Seibold
    Cc: Roland Dreier
    Cc: Dmitry Torokhov
    Cc: Andy Walls
    Cc: Vikram Dhillon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     
  • Fix a wrong optimization in include/linux/kfifo.h which could cause a race
    in kfifo_out_locked.

    Signed-off-by: Stefani Seibold
    Reported-by: Johan Hovold
    Cc: Pete Zaitcev
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     

31 Dec, 2009

1 commit


24 Dec, 2009

1 commit

  • Fix kernel-doc errors and warnings in new header file kfifo.h.
    Don't use kernel-doc "/**" for internal functions whose comments
    are not in kernel-doc format.

    kernel-doc section header names (like "Note:") must be unique
    per function. Looks like I need to document that.

    Error(include/linux/kfifo.h:76): duplicate section name 'Note'
    Warning(include/linux/kfifo.h:88): Excess function parameter 'size' description in 'INIT_KFIFO'
    Error(include/linux/kfifo.h:101): duplicate section name 'Note'
    Warning(include/linux/kfifo.h:257): No description found for parameter 'fifo'
    (many of this last type, from internal functions)

    Signed-off-by: Randy Dunlap
    Cc: Stefani Seibold
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

23 Dec, 2009

8 commits

  • Add kfifo_in_rec() - puts some record data into the FIFO
    Add kfifo_out_rec() - gets some record data from the FIFO
    Add kfifo_from_user_rec() - puts some data from user space into the FIFO
    Add kfifo_to_user_rec() - gets data from the FIFO and write it to user space
    Add kfifo_peek_rec() - gets the size of the next FIFO record field
    Add kfifo_skip_rec() - skip the next fifo out record
    Add kfifo_avail_rec() - determinate the number of bytes available in a record FIFO

    Signed-off-by: Stefani Seibold
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • Add kfifo_reset_out() for save lockless discard the fifo output
    Add kfifo_skip() to skip a number of output bytes
    Add kfifo_from_user() to copy user space data into the fifo
    Add kfifo_to_user() to copy fifo data to user space

    Signed-off-by: Stefani Seibold
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • Add DECLARE_KFIFO - macro to declare a kfifo and the associated buffer inside a struct
    Add INIT_KFIFO - Initialize a kfifo declared by DECLARED_KFIFO
    Add DEFINE_KFIFO - macro to define and initialize a kfifo as a global or local object
    Add kfifo_size() - returns the size of the fifo in bytes
    Add kfifo_is_empty() - returns true if the fifo is empty
    Add kfifo_is_full() - returns true if the fifo is full
    Add kfifo_avail() - returns the number of bytes available in the FIFO
    Do some code cleanup

    Signed-off-by: Stefani Seibold
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • Fix the "ignoring return value of '...', declared with attribute
    warn_unused_result" compiler warning in several users of the new kfifo
    API.

    It removes the __must_check attribute from kfifo_in() and
    kfifo_in_locked() which must not necessary performed.

    Fix the allocation bug in the nozomi driver file, by moving out the
    kfifo_alloc from the interrupt handler into the probe function.

    Fix the kfifo_out() and kfifo_out_locked() users to handle a unexpected
    end of fifo.

    Signed-off-by: Stefani Seibold
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • rename kfifo_put... into kfifo_in... to prevent miss use of old non in
    kernel-tree drivers

    ditto for kfifo_get... -> kfifo_out...

    Improve the prototypes of kfifo_in and kfifo_out to make the kerneldoc
    annotations more readable.

    Add mini "howto porting to the new API" in kfifo.h

    Signed-off-by: Stefani Seibold
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • change name of __kfifo_* functions to kfifo_*, because the prefix __kfifo
    should be reserved for internal functions only.

    Signed-off-by: Stefani Seibold
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • Move the pointer to the spinlock out of struct kfifo. Most users in
    tree do not actually use a spinlock, so the few exceptions now have to
    call kfifo_{get,put}_locked, which takes an extra argument to a
    spinlock.

    Signed-off-by: Stefani Seibold
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     
  • 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
    Acked-by: Greg Kroah-Hartman
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Andi Kleen
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefani Seibold
     

20 Sep, 2009

1 commit

  • Currently kfifo cannot be used by parts of the kernel that use "const"
    properly as kfifo itself does not use const for passed data blocks which
    are indeed const.

    Signed-off-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Alan Cox
     

30 Apr, 2008

1 commit


12 Feb, 2007

1 commit

  • A variety of (mostly) innocuous fixes to the embedded kernel-doc content in
    source files, including:

    * make multi-line initial descriptions single line
    * denote some function names, constants and structs as such
    * change erroneous opening '/*' to '/**' in a few places
    * reword some text for clarity

    Signed-off-by: Robert P. J. Day
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

09 Oct, 2005

1 commit

  • - added typedef unsigned int __nocast gfp_t;

    - replaced __nocast uses for gfp flags with gfp_t - it gives exactly
    the same warnings as far as sparse is concerned, doesn't change
    generated code (from gcc point of view we replaced unsigned int with
    typedef) and documents what's going on far better.

    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Al Viro
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds