@@ -74,5 +74,7 @@ static inline unsigned int kfifo_len(struct kfifo *fifo)
void kfifo_putc(struct kfifo *fifo, unsigned char c);
unsigned int kfifo_getc(struct kfifo *fifo, unsigned char *c);
+void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c));
+
#endif
@@ -154,3 +154,24 @@ unsigned int kfifo_getc(struct kfifo *fifo, unsigned char *c)
return 0;
}
+void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c))
+{
+ int i;
+ unsigned char *c;
+ unsigned int l;
+ unsigned int len;
+
+ len = fifo->in - fifo->out;
+
+ /* first get the data from fifo->out until the end of the buffer */
+ l = min(len, fifo->size - (fifo->out & (fifo->size - 1)));
+ c = fifo->buffer + (fifo->out & (fifo->size - 1));
+ for (i = 0; i < l; i++)
+ dump(c[i]);
+
+ /* then get the rest (if any) from the beginning of the buffer */
+ c = fifo->buffer;
+ l = len - l;
+ for (i = 0; i < l; i++)
+ dump(c[i]);
+}
This will allow to implement a dmesg mecanism in barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- include/kfifo.h | 2 ++ lib/kfifo.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)