Re: [PATCH 1/2] Use kfifo to buffer USB generic serial writes

From: Alan Cox
Date: Fri Aug 14 2009 - 17:19:48 EST


> The first part of patch uses the kfifo infrastructure to implement a write
> FIFO that accurately returns the amount of space available in the buffer. The
> second makes a minor change to kfifo_put() and __kfifo_put() to add the "const"
> attribute to their input buffer pointers.

Nice, fixes the bug, uses the proper infrastructure and comes out as
loads less code and far easier to read


> + /* TODO: Much of the time there won't be a write pending and won't be
> + * any data ahead of the current chunk. In those cases, we could save
> + * a copy by putting the data directly into the URB transfer buffer.
> + * This adds some complexity, is it worth it for serial I/O? */
> + count = kfifo_put(port->write_fifo, buf, count);

If your device has a single transmit URB and isn't doing 2-3MBit the
answer will be no - its in cache anyway and the real hit will be the
writeout for the USB controller to DMA it.


> + spin_lock_irqsave(&port->write_fifo_lock, flags);
> + chars = __kfifo_len(port->write_fifo);
> + spin_unlock_irqrestore(&port->write_fifo_lock, flags);

Any reason for not using kfifo_len() ?

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/