Skip to content

Commit

Permalink
kfifo: use void * pointers for user buffers
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Stefani Seibold <[email protected]>
Cc: Roland Dreier <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Andy Walls <[email protected]>
Cc: Vikram Dhillon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Andi Kleen authored and torvalds committed Jan 16, 2010
1 parent 2427b8e commit 8ecc295
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions include/linux/kfifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ union { \

#undef __kfifo_initializer

extern void kfifo_init(struct kfifo *fifo, unsigned char *buffer,
extern void kfifo_init(struct kfifo *fifo, void *buffer,
unsigned int size);
extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size,
gfp_t gfp_mask);
extern void kfifo_free(struct kfifo *fifo);
extern unsigned int kfifo_in(struct kfifo *fifo,
const unsigned char *from, unsigned int len);
const void *from, unsigned int len);
extern __must_check unsigned int kfifo_out(struct kfifo *fifo,
unsigned char *to, unsigned int len);
void *to, unsigned int len);

/**
* kfifo_reset - removes the entire FIFO contents
Expand Down Expand Up @@ -194,7 +194,7 @@ static inline __must_check unsigned int kfifo_avail(struct kfifo *fifo)
* bytes copied.
*/
static inline unsigned int kfifo_in_locked(struct kfifo *fifo,
const unsigned char *from, unsigned int n, spinlock_t *lock)
const void *from, unsigned int n, spinlock_t *lock)
{
unsigned long flags;
unsigned int ret;
Expand All @@ -219,7 +219,7 @@ static inline unsigned int kfifo_in_locked(struct kfifo *fifo,
* @to buffer and returns the number of copied bytes.
*/
static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
unsigned char *to, unsigned int n, spinlock_t *lock)
void *to, unsigned int n, spinlock_t *lock)
{
unsigned long flags;
unsigned int ret;
Expand Down
8 changes: 4 additions & 4 deletions kernel/kfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <linux/log2.h>
#include <linux/uaccess.h>

static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
static void _kfifo_init(struct kfifo *fifo, void *buffer,
unsigned int size)
{
fifo->buffer = buffer;
Expand All @@ -44,7 +44,7 @@ static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
* @size: the size of the internal buffer, this have to be a power of 2.
*
*/
void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size)
void kfifo_init(struct kfifo *fifo, void *buffer, unsigned int size)
{
/* size must be a power of 2 */
BUG_ON(!is_power_of_2(size));
Expand Down Expand Up @@ -235,7 +235,7 @@ EXPORT_SYMBOL(__kfifo_in_n);
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these functions.
*/
unsigned int kfifo_in(struct kfifo *fifo, const unsigned char *from,
unsigned int kfifo_in(struct kfifo *fifo, const void *from,
unsigned int len)
{
len = min(kfifo_avail(fifo), len);
Expand Down Expand Up @@ -277,7 +277,7 @@ EXPORT_SYMBOL(__kfifo_out_n);
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these functions.
*/
unsigned int kfifo_out(struct kfifo *fifo, unsigned char *to, unsigned int len)
unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len)
{
len = min(kfifo_len(fifo), len);

Expand Down

0 comments on commit 8ecc295

Please sign in to comment.