[lkml]   [2004]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [RFC, 2.6] a simple FIFO implementation
    On Monday 13 September 2004 08:52 am, Stelian Pop wrote:
    > +static inline unsigned int kfifo_len(struct kfifo *fifo) {
    > +       unsigned long flags;
    > +       unsigned int result;
    > +       
    > +       spin_lock_irqsave(&fifo->lock, flags);
    > +       
    > +       result = fifo->len;
    > +
    > +       spin_unlock_irqrestore(&fifo->lock, flags);
    > +
    > +       return result;
    > +}


    I do not think that taking/releasing spinlock here serves any purpose as
    len can get canged right after releasing the lock and therefore no longer
    valid... And relying on result of kfifo_len to decide if the FIF can be
    drained is not reliable so probably the inteface is better off without this

    Also I think that most users would put only sertain structures (homogenous?)
    in their FIFOs so maybe it should be:

    struct kfifo *kfifo_alloc(unsigned int el_size, unsigned int len)
    unsigned int kfifo_put(struct kfifo *fifo, void *buffer)
    unsigned int kfifo_get(struct kfifo *fifo, void *buffer)

    Also, don't we have a rule that for functions the opening curly brace should
    be on a new line?

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:06    [W:0.021 / U:6.564 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site