aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2009-12-21 17:37:27 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-22 17:17:56 -0500
commitc1e13f25674ed564948ecb7dfe5f83e578892896 (patch)
tree24fac07b3e2b66dff01c3127b34077de1de4c101 /kernel
parent45465487897a1c6d508b14b904dc5777f7ec7e04 (diff)
kfifo: move out spinlock
Move the pointer to the spinlock out of struct kfifo. Most users in tree do not actually use a spinlock, so the few exceptions now have to call kfifo_{get,put}_locked, which takes an extra argument to a spinlock. 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 'kernel')
-rw-r--r--kernel/kfifo.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 8da6bb9782bb..4950bdbe3477 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -28,11 +28,10 @@
28#include <linux/log2.h> 28#include <linux/log2.h>
29 29
30static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer, 30static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
31 unsigned int size, spinlock_t *lock) 31 unsigned int size)
32{ 32{
33 fifo->buffer = buffer; 33 fifo->buffer = buffer;
34 fifo->size = size; 34 fifo->size = size;
35 fifo->lock = lock;
36 35
37 kfifo_reset(fifo); 36 kfifo_reset(fifo);
38} 37}
@@ -42,16 +41,14 @@ static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
42 * @fifo: the fifo to assign the buffer 41 * @fifo: the fifo to assign the buffer
43 * @buffer: the preallocated buffer to be used. 42 * @buffer: the preallocated buffer to be used.
44 * @size: the size of the internal buffer, this have to be a power of 2. 43 * @size: the size of the internal buffer, this have to be a power of 2.
45 * @lock: the lock to be used to protect the fifo buffer
46 * 44 *
47 */ 45 */
48void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size, 46void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size)
49 spinlock_t *lock)
50{ 47{
51 /* size must be a power of 2 */ 48 /* size must be a power of 2 */
52 BUG_ON(!is_power_of_2(size)); 49 BUG_ON(!is_power_of_2(size));
53 50
54 _kfifo_init(fifo, buffer, size, lock); 51 _kfifo_init(fifo, buffer, size);
55} 52}
56EXPORT_SYMBOL(kfifo_init); 53EXPORT_SYMBOL(kfifo_init);
57 54
@@ -60,7 +57,6 @@ EXPORT_SYMBOL(kfifo_init);
60 * @fifo: the fifo to assign then new buffer 57 * @fifo: the fifo to assign then new buffer
61 * @size: the size of the buffer to be allocated, this have to be a power of 2. 58 * @size: the size of the buffer to be allocated, this have to be a power of 2.
62 * @gfp_mask: get_free_pages mask, passed to kmalloc() 59 * @gfp_mask: get_free_pages mask, passed to kmalloc()
63 * @lock: the lock to be used to protect the fifo buffer
64 * 60 *
65 * This function dynamically allocates a new fifo internal buffer 61 * This function dynamically allocates a new fifo internal buffer
66 * 62 *
@@ -68,8 +64,7 @@ EXPORT_SYMBOL(kfifo_init);
68 * The buffer will be release with kfifo_free(). 64 * The buffer will be release with kfifo_free().
69 * Return 0 if no error, otherwise the an error code 65 * Return 0 if no error, otherwise the an error code
70 */ 66 */
71int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask, 67int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask)
72 spinlock_t *lock)
73{ 68{
74 unsigned char *buffer; 69 unsigned char *buffer;
75 70
@@ -84,11 +79,11 @@ int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask,
84 79
85 buffer = kmalloc(size, gfp_mask); 80 buffer = kmalloc(size, gfp_mask);
86 if (!buffer) { 81 if (!buffer) {
87 _kfifo_init(fifo, 0, 0, NULL); 82 _kfifo_init(fifo, 0, 0);
88 return -ENOMEM; 83 return -ENOMEM;
89 } 84 }
90 85
91 _kfifo_init(fifo, buffer, size, lock); 86 _kfifo_init(fifo, buffer, size);
92 87
93 return 0; 88 return 0;
94} 89}