summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/serial2002.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-04-05 16:07:49 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-08 10:27:43 -0700
commit32ef0e3e308f59413ba2da42717a884362bf2efc (patch)
tree6fc6d9634a7b3a7693213a4c017093091b774232 /drivers/staging/comedi/drivers/serial2002.c
parent4445d254cdc59d535616d61f3b7b7cd573e95cf4 (diff)
staging: comedi: serial2002: fix different address space sparse warnings
The struct file_operations (*read) and (*write) operations expect the buffer to be a __user space pointer. Currently the (*write) operations in this driver cause this warning: warning: incorrect type in argument 2 (different address spaces) expected char const [noderef] <asn:1>*<noident> got unsigned char [usertype] *buf And the (*read) operations cause this warning: warning: incorrect type in argument 2 (different address spaces) expected char [noderef] <asn:1>*<noident> got unsigned char *<noident> Use __force to cast the buffer to a __user pointer to suppress the warnings. Consolidate the (*read) calls into a helper function, __tty_readb(). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/serial2002.c')
-rw-r--r--drivers/staging/comedi/drivers/serial2002.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index e6177b48ccaf..75c86ae6f844 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -82,17 +82,26 @@ static long tty_ioctl(struct file *f, unsigned op, unsigned long param)
static int tty_write(struct file *f, unsigned char *buf, int count)
{
+ const char __user *p = (__force const char __user *)buf;
int result;
mm_segment_t oldfs;
oldfs = get_fs();
set_fs(KERNEL_DS);
f->f_pos = 0;
- result = f->f_op->write(f, buf, count, &f->f_pos);
+ result = f->f_op->write(f, p, count, &f->f_pos);
set_fs(oldfs);
return result;
}
+static int __tty_readb(struct file *f, unsigned char *buf)
+{
+ char __user *p = (__force char __user *)buf;
+
+ f->f_pos = 0;
+ return f->f_op->read(f, p, 1, &f->f_pos);
+}
+
#if 0
/*
* On 2.6.26.3 this occaisonally gave me page faults, worked around by
@@ -113,6 +122,7 @@ static int tty_available(struct file *f)
static int tty_read(struct file *f, int timeout)
{
+ unsigned char ch;
int result;
result = -1;
@@ -147,25 +157,18 @@ static int tty_read(struct file *f, int timeout)
elapsed) * HZ) / 10000);
}
poll_freewait(&table);
- {
- unsigned char ch;
- f->f_pos = 0;
- if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1)
- result = ch;
- }
+ if (__tty_readb(f, &ch) == 1)
+ result = ch;
} else {
/* Device does not support poll, busy wait */
int retries = 0;
while (1) {
- unsigned char ch;
-
retries++;
if (retries >= timeout)
break;
- f->f_pos = 0;
- if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) {
+ if (__tty_readb(f, &ch) == 1) {
result = ch;
break;
}