From a4f3e9b95420a14c0d16f9f71910d4307ba035af Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Fri, 15 Jan 2010 17:01:16 -0800 Subject: [PATCH] --- yaml --- r: 179347 b: refs/heads/master c: a5b9e2c1063046421ce01dcf5ddd7ec12567f3e1 h: refs/heads/master i: 179345: ee1208e8309f955a59d258a8d4cb48d5bfc87e77 179343: 88b1043815f06d70ab6ebb83dcda68cb4caafc19 v: v3 --- [refs] | 2 +- trunk/include/linux/kfifo.h | 3 +++ trunk/kernel/kfifo.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index cf4dd7728d57..8b70ddc1c79e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 64ce1037c5434b1d036cd99ecaee6e00496bc2e9 +refs/heads/master: a5b9e2c1063046421ce01dcf5ddd7ec12567f3e1 diff --git a/trunk/include/linux/kfifo.h b/trunk/include/linux/kfifo.h index 86ad50a900c8..7ad6d32dd673 100644 --- a/trunk/include/linux/kfifo.h +++ b/trunk/include/linux/kfifo.h @@ -113,6 +113,9 @@ extern unsigned int kfifo_in(struct kfifo *fifo, const void *from, unsigned int len); extern __must_check unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len); +extern __must_check unsigned int kfifo_out_peek(struct kfifo *fifo, + void *to, unsigned int len, unsigned offset); + /** * kfifo_reset - removes the entire FIFO contents diff --git a/trunk/kernel/kfifo.c b/trunk/kernel/kfifo.c index b50bb622e8b0..7384f120be87 100644 --- a/trunk/kernel/kfifo.c +++ b/trunk/kernel/kfifo.c @@ -302,6 +302,27 @@ unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len) } EXPORT_SYMBOL(kfifo_out); +/** + * kfifo_out_peek - copy some data from the FIFO, but do not remove it + * @fifo: the fifo to be used. + * @to: where the data must be copied. + * @len: the size of the destination buffer. + * @offset: offset into the fifo + * + * This function copies at most @len bytes at @offset from the FIFO + * into the @to buffer and returns the number of copied bytes. + * The data is not removed from the FIFO. + */ +unsigned int kfifo_out_peek(struct kfifo *fifo, void *to, unsigned int len, + unsigned offset) +{ + len = min(kfifo_len(fifo), len + offset); + + __kfifo_out_data(fifo, to, len, offset); + return len; +} +EXPORT_SYMBOL(kfifo_out_peek); + unsigned int __kfifo_out_generic(struct kfifo *fifo, void *to, unsigned int len, unsigned int recsize, unsigned int *total)