aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kfifo.h
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2009-12-21 17:37:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-22 17:17:56 -0500
commita121f24accac1600bf5b6fb1e12eeabdfed7cb1a (patch)
tree24a3bb527e50304677785dbb390dd5ff838c94e8 /include/linux/kfifo.h
parent37bdfbbfaab47811fcec84dff23c4e8da1a09f9e (diff)
kfifo: add kfifo_skip, kfifo_from_user and kfifo_to_user
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 <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kfifo.h')
-rw-r--r--include/linux/kfifo.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index dd53eed3e2af..d3230fb08bc7 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -125,6 +125,16 @@ static inline void kfifo_reset(struct kfifo *fifo)
125} 125}
126 126
127/** 127/**
128 * kfifo_reset_out - skip FIFO contents
129 * @fifo: the fifo to be emptied.
130 */
131static inline void kfifo_reset_out(struct kfifo *fifo)
132{
133 smp_mb();
134 fifo->out = fifo->in;
135}
136
137/**
128 * kfifo_size - returns the size of the fifo in bytes 138 * kfifo_size - returns the size of the fifo in bytes
129 * @fifo: the fifo to be used. 139 * @fifo: the fifo to be used.
130 */ 140 */
@@ -231,4 +241,41 @@ static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
231 return ret; 241 return ret;
232} 242}
233 243
244extern void kfifo_skip(struct kfifo *fifo, unsigned int len);
245
246extern __must_check unsigned int kfifo_from_user(struct kfifo *fifo,
247 const void __user *from, unsigned int n);
248
249extern __must_check unsigned int kfifo_to_user(struct kfifo *fifo,
250 void __user *to, unsigned int n);
251
252/**
253 * __kfifo_add_out internal helper function for updating the out offset
254 */
255static inline void __kfifo_add_out(struct kfifo *fifo,
256 unsigned int off)
257{
258 smp_mb();
259 fifo->out += off;
260}
261
262/**
263 * __kfifo_add_in internal helper function for updating the in offset
264 */
265static inline void __kfifo_add_in(struct kfifo *fifo,
266 unsigned int off)
267{
268 smp_wmb();
269 fifo->in += off;
270}
271
272/**
273 * __kfifo_off internal helper function for calculating the index of a
274 * given offeset
275 */
276static inline unsigned int __kfifo_off(struct kfifo *fifo, unsigned int off)
277{
278 return off & (fifo->size - 1);
279}
280
234#endif 281#endif