Commit 8ecc2951534af10e04ddb5e5ff5c6d217b79f5c2
Committed by
Linus Torvalds
1 parent
2427b8e3ea
Exists in
master
and in
4 other branches
kfifo: use void * pointers for user buffers
The pointers to user buffers are currently unsigned char *, which requires a lot of casting in the caller for any non-char typed buffers. Use void * instead. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Stefani Seibold <stefani@seibold.net> Cc: Roland Dreier <rdreier@cisco.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Andy Walls <awalls@radix.net> Cc: Vikram Dhillon <dhillonv10@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 9 additions and 9 deletions Side-by-side Diff
include/linux/kfifo.h
... | ... | @@ -104,15 +104,15 @@ |
104 | 104 | |
105 | 105 | #undef __kfifo_initializer |
106 | 106 | |
107 | -extern void kfifo_init(struct kfifo *fifo, unsigned char *buffer, | |
107 | +extern void kfifo_init(struct kfifo *fifo, void *buffer, | |
108 | 108 | unsigned int size); |
109 | 109 | extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size, |
110 | 110 | gfp_t gfp_mask); |
111 | 111 | extern void kfifo_free(struct kfifo *fifo); |
112 | 112 | extern unsigned int kfifo_in(struct kfifo *fifo, |
113 | - const unsigned char *from, unsigned int len); | |
113 | + const void *from, unsigned int len); | |
114 | 114 | extern __must_check unsigned int kfifo_out(struct kfifo *fifo, |
115 | - unsigned char *to, unsigned int len); | |
115 | + void *to, unsigned int len); | |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * kfifo_reset - removes the entire FIFO contents |
... | ... | @@ -194,7 +194,7 @@ |
194 | 194 | * bytes copied. |
195 | 195 | */ |
196 | 196 | static inline unsigned int kfifo_in_locked(struct kfifo *fifo, |
197 | - const unsigned char *from, unsigned int n, spinlock_t *lock) | |
197 | + const void *from, unsigned int n, spinlock_t *lock) | |
198 | 198 | { |
199 | 199 | unsigned long flags; |
200 | 200 | unsigned int ret; |
... | ... | @@ -219,7 +219,7 @@ |
219 | 219 | * @to buffer and returns the number of copied bytes. |
220 | 220 | */ |
221 | 221 | static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo, |
222 | - unsigned char *to, unsigned int n, spinlock_t *lock) | |
222 | + void *to, unsigned int n, spinlock_t *lock) | |
223 | 223 | { |
224 | 224 | unsigned long flags; |
225 | 225 | unsigned int ret; |
kernel/kfifo.c
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | #include <linux/log2.h> |
29 | 29 | #include <linux/uaccess.h> |
30 | 30 | |
31 | -static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer, | |
31 | +static void _kfifo_init(struct kfifo *fifo, void *buffer, | |
32 | 32 | unsigned int size) |
33 | 33 | { |
34 | 34 | fifo->buffer = buffer; |
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 | * @size: the size of the internal buffer, this have to be a power of 2. |
45 | 45 | * |
46 | 46 | */ |
47 | -void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size) | |
47 | +void kfifo_init(struct kfifo *fifo, void *buffer, unsigned int size) | |
48 | 48 | { |
49 | 49 | /* size must be a power of 2 */ |
50 | 50 | BUG_ON(!is_power_of_2(size)); |
... | ... | @@ -235,7 +235,7 @@ |
235 | 235 | * Note that with only one concurrent reader and one concurrent |
236 | 236 | * writer, you don't need extra locking to use these functions. |
237 | 237 | */ |
238 | -unsigned int kfifo_in(struct kfifo *fifo, const unsigned char *from, | |
238 | +unsigned int kfifo_in(struct kfifo *fifo, const void *from, | |
239 | 239 | unsigned int len) |
240 | 240 | { |
241 | 241 | len = min(kfifo_avail(fifo), len); |
... | ... | @@ -277,7 +277,7 @@ |
277 | 277 | * Note that with only one concurrent reader and one concurrent |
278 | 278 | * writer, you don't need extra locking to use these functions. |
279 | 279 | */ |
280 | -unsigned int kfifo_out(struct kfifo *fifo, unsigned char *to, unsigned int len) | |
280 | +unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len) | |
281 | 281 | { |
282 | 282 | len = min(kfifo_len(fifo), len); |
283 | 283 |