Commit 9d02c2be authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: lots of sparse fixups for usbfs

parent 872b2a59
...@@ -49,14 +49,14 @@ ...@@ -49,14 +49,14 @@
#include "hcd.h" /* for usbcore internals */ #include "hcd.h" /* for usbcore internals */
struct async { struct async {
struct list_head asynclist; struct list_head asynclist;
struct dev_state *ps; struct dev_state *ps;
struct task_struct *task; struct task_struct *task;
unsigned int signr; unsigned int signr;
unsigned int intf; unsigned int intf;
void *userbuffer; void __user *userbuffer;
void *userurb; void __user *userurb;
struct urb *urb; struct urb *urb;
}; };
static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
...@@ -83,7 +83,7 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) ...@@ -83,7 +83,7 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
return ret; return ret;
} }
static ssize_t usbdev_read(struct file *file, char * buf, size_t nbytes, loff_t *ppos) static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
{ {
struct dev_state *ps = (struct dev_state *)file->private_data; struct dev_state *ps = (struct dev_state *)file->private_data;
ssize_t ret = 0; ssize_t ret = 0;
...@@ -235,7 +235,7 @@ extern __inline__ struct async *async_getcompleted(struct dev_state *ps) ...@@ -235,7 +235,7 @@ extern __inline__ struct async *async_getcompleted(struct dev_state *ps)
return as; return as;
} }
extern __inline__ struct async *async_getpending(struct dev_state *ps, void *userurb) extern __inline__ struct async *async_getpending(struct dev_state *ps, void __user *userurb)
{ {
unsigned long flags; unsigned long flags;
struct async *as; struct async *as;
...@@ -265,7 +265,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs) ...@@ -265,7 +265,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
sinfo.si_signo = as->signr; sinfo.si_signo = as->signr;
sinfo.si_errno = as->urb->status; sinfo.si_errno = as->urb->status;
sinfo.si_code = SI_ASYNCIO; sinfo.si_code = SI_ASYNCIO;
sinfo.si_addr = as->userurb; sinfo.si_addr = (void *)as->userurb;
send_sig_info(as->signr, &sinfo, as->task); send_sig_info(as->signr, &sinfo, as->task);
} }
} }
...@@ -536,7 +536,7 @@ static int usbdev_release(struct inode *inode, struct file *file) ...@@ -536,7 +536,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
static int proc_control(struct dev_state *ps, void *arg) static int proc_control(struct dev_state *ps, void __user *arg)
{ {
struct usb_device *dev = ps->dev; struct usb_device *dev = ps->dev;
struct usbdevfs_ctrltransfer ctrl; struct usbdevfs_ctrltransfer ctrl;
...@@ -544,7 +544,7 @@ static int proc_control(struct dev_state *ps, void *arg) ...@@ -544,7 +544,7 @@ static int proc_control(struct dev_state *ps, void *arg)
unsigned char *tbuf; unsigned char *tbuf;
int i, ret; int i, ret;
if (copy_from_user(&ctrl, (void *)arg, sizeof(ctrl))) if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
return -EFAULT; return -EFAULT;
if ((ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex))) if ((ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex)))
return ret; return ret;
...@@ -586,7 +586,7 @@ static int proc_control(struct dev_state *ps, void *arg) ...@@ -586,7 +586,7 @@ static int proc_control(struct dev_state *ps, void *arg)
return i; return i;
} }
static int proc_bulk(struct dev_state *ps, void *arg) static int proc_bulk(struct dev_state *ps, void __user *arg)
{ {
struct usb_device *dev = ps->dev; struct usb_device *dev = ps->dev;
struct usbdevfs_bulktransfer bulk; struct usbdevfs_bulktransfer bulk;
...@@ -595,7 +595,7 @@ static int proc_bulk(struct dev_state *ps, void *arg) ...@@ -595,7 +595,7 @@ static int proc_bulk(struct dev_state *ps, void *arg)
unsigned char *tbuf; unsigned char *tbuf;
int i, ret; int i, ret;
if (copy_from_user(&bulk, (void *)arg, sizeof(bulk))) if (copy_from_user(&bulk, arg, sizeof(bulk)))
return -EFAULT; return -EFAULT;
if ((ret = findintfep(ps->dev, bulk.ep)) < 0) if ((ret = findintfep(ps->dev, bulk.ep)) < 0)
return ret; return ret;
...@@ -641,12 +641,12 @@ static int proc_bulk(struct dev_state *ps, void *arg) ...@@ -641,12 +641,12 @@ static int proc_bulk(struct dev_state *ps, void *arg)
return len2; return len2;
} }
static int proc_resetep(struct dev_state *ps, void *arg) static int proc_resetep(struct dev_state *ps, void __user *arg)
{ {
unsigned int ep; unsigned int ep;
int ret; int ret;
if (get_user(ep, (unsigned int *)arg)) if (get_user(ep, (unsigned int __user *)arg))
return -EFAULT; return -EFAULT;
if ((ret = findintfep(ps->dev, ep)) < 0) if ((ret = findintfep(ps->dev, ep)) < 0)
return ret; return ret;
...@@ -656,13 +656,13 @@ static int proc_resetep(struct dev_state *ps, void *arg) ...@@ -656,13 +656,13 @@ static int proc_resetep(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_clearhalt(struct dev_state *ps, void *arg) static int proc_clearhalt(struct dev_state *ps, void __user *arg)
{ {
unsigned int ep; unsigned int ep;
int pipe; int pipe;
int ret; int ret;
if (get_user(ep, (unsigned int *)arg)) if (get_user(ep, (unsigned int __user *)arg))
return -EFAULT; return -EFAULT;
if ((ret = findintfep(ps->dev, ep)) < 0) if ((ret = findintfep(ps->dev, ep)) < 0)
return ret; return ret;
...@@ -677,7 +677,7 @@ static int proc_clearhalt(struct dev_state *ps, void *arg) ...@@ -677,7 +677,7 @@ static int proc_clearhalt(struct dev_state *ps, void *arg)
} }
static int proc_getdriver(struct dev_state *ps, void *arg) static int proc_getdriver(struct dev_state *ps, void __user *arg)
{ {
struct usbdevfs_getdriver gd; struct usbdevfs_getdriver gd;
struct usb_interface *interface; struct usb_interface *interface;
...@@ -698,7 +698,7 @@ static int proc_getdriver(struct dev_state *ps, void *arg) ...@@ -698,7 +698,7 @@ static int proc_getdriver(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_connectinfo(struct dev_state *ps, void *arg) static int proc_connectinfo(struct dev_state *ps, void __user *arg)
{ {
struct usbdevfs_connectinfo ci; struct usbdevfs_connectinfo ci;
...@@ -733,7 +733,7 @@ static int proc_resetdevice(struct dev_state *ps) ...@@ -733,7 +733,7 @@ static int proc_resetdevice(struct dev_state *ps)
return 0; return 0;
} }
static int proc_setintf(struct dev_state *ps, void *arg) static int proc_setintf(struct dev_state *ps, void __user *arg)
{ {
struct usbdevfs_setinterface setintf; struct usbdevfs_setinterface setintf;
struct usb_interface *interface; struct usb_interface *interface;
...@@ -755,18 +755,18 @@ static int proc_setintf(struct dev_state *ps, void *arg) ...@@ -755,18 +755,18 @@ static int proc_setintf(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_setconfig(struct dev_state *ps, void *arg) static int proc_setconfig(struct dev_state *ps, void __user *arg)
{ {
unsigned int u; unsigned int u;
if (get_user(u, (unsigned int *)arg)) if (get_user(u, (unsigned int __user *)arg))
return -EFAULT; return -EFAULT;
if (usb_set_configuration(ps->dev, u) < 0) if (usb_set_configuration(ps->dev, u) < 0)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
static int proc_submiturb(struct dev_state *ps, void *arg) static int proc_submiturb(struct dev_state *ps, void __user *arg)
{ {
struct usbdevfs_urb uurb; struct usbdevfs_urb uurb;
struct usbdevfs_iso_packet_desc *isopkt = NULL; struct usbdevfs_iso_packet_desc *isopkt = NULL;
...@@ -804,7 +804,7 @@ static int proc_submiturb(struct dev_state *ps, void *arg) ...@@ -804,7 +804,7 @@ static int proc_submiturb(struct dev_state *ps, void *arg)
return -EINVAL; return -EINVAL;
if (!(dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) if (!(dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
if (copy_from_user(dr, (unsigned char*)uurb.buffer, 8)) { if (copy_from_user(dr, uurb.buffer, 8)) {
kfree(dr); kfree(dr);
return -EFAULT; return -EFAULT;
} }
...@@ -930,7 +930,7 @@ static int proc_submiturb(struct dev_state *ps, void *arg) ...@@ -930,7 +930,7 @@ static int proc_submiturb(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_unlinkurb(struct dev_state *ps, void *arg) static int proc_unlinkurb(struct dev_state *ps, void __user *arg)
{ {
struct async *as; struct async *as;
...@@ -972,11 +972,11 @@ static int processcompl(struct async *as) ...@@ -972,11 +972,11 @@ static int processcompl(struct async *as)
return 0; return 0;
} }
static int proc_reapurb(struct dev_state *ps, void *arg) static int proc_reapurb(struct dev_state *ps, void __user *arg)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
struct async *as = NULL; struct async *as = NULL;
void *addr; void __user *addr;
int ret; int ret;
add_wait_queue(&ps->wait, &wait); add_wait_queue(&ps->wait, &wait);
...@@ -1007,10 +1007,10 @@ static int proc_reapurb(struct dev_state *ps, void *arg) ...@@ -1007,10 +1007,10 @@ static int proc_reapurb(struct dev_state *ps, void *arg)
return -EIO; return -EIO;
} }
static int proc_reapurbnonblock(struct dev_state *ps, void *arg) static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)
{ {
struct async *as; struct async *as;
void *addr; void __user *addr;
int ret; int ret;
if (!(as = async_getcompleted(ps))) if (!(as = async_getcompleted(ps)))
...@@ -1025,7 +1025,7 @@ static int proc_reapurbnonblock(struct dev_state *ps, void *arg) ...@@ -1025,7 +1025,7 @@ static int proc_reapurbnonblock(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_disconnectsignal(struct dev_state *ps, void *arg) static int proc_disconnectsignal(struct dev_state *ps, void __user *arg)
{ {
struct usbdevfs_disconnectsignal ds; struct usbdevfs_disconnectsignal ds;
...@@ -1038,24 +1038,24 @@ static int proc_disconnectsignal(struct dev_state *ps, void *arg) ...@@ -1038,24 +1038,24 @@ static int proc_disconnectsignal(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_claiminterface(struct dev_state *ps, void *arg) static int proc_claiminterface(struct dev_state *ps, void __user *arg)
{ {
unsigned int intf; unsigned int intf;
int ret; int ret;
if (get_user(intf, (unsigned int *)arg)) if (get_user(intf, (unsigned int __user *)arg))
return -EFAULT; return -EFAULT;
if ((ret = findintfif(ps->dev, intf)) < 0) if ((ret = findintfif(ps->dev, intf)) < 0)
return ret; return ret;
return claimintf(ps, ret); return claimintf(ps, ret);
} }
static int proc_releaseinterface(struct dev_state *ps, void *arg) static int proc_releaseinterface(struct dev_state *ps, void __user *arg)
{ {
unsigned int intf; unsigned int intf;
int ret; int ret;
if (get_user(intf, (unsigned int *)arg)) if (get_user(intf, (unsigned int __user *)arg))
return -EFAULT; return -EFAULT;
if ((ret = findintfif(ps->dev, intf)) < 0) if ((ret = findintfif(ps->dev, intf)) < 0)
return ret; return ret;
...@@ -1065,7 +1065,7 @@ static int proc_releaseinterface(struct dev_state *ps, void *arg) ...@@ -1065,7 +1065,7 @@ static int proc_releaseinterface(struct dev_state *ps, void *arg)
return 0; return 0;
} }
static int proc_ioctl (struct dev_state *ps, void *arg) static int proc_ioctl (struct dev_state *ps, void __user *arg)
{ {
struct usbdevfs_ioctl ctrl; struct usbdevfs_ioctl ctrl;
int size; int size;
...@@ -1075,7 +1075,7 @@ static int proc_ioctl (struct dev_state *ps, void *arg) ...@@ -1075,7 +1075,7 @@ static int proc_ioctl (struct dev_state *ps, void *arg)
struct usb_driver *driver = 0; struct usb_driver *driver = 0;
/* get input parameters and alloc buffer */ /* get input parameters and alloc buffer */
if (copy_from_user(&ctrl, (void *) arg, sizeof (ctrl))) if (copy_from_user(&ctrl, arg, sizeof (ctrl)))
return -EFAULT; return -EFAULT;
if ((size = _IOC_SIZE (ctrl.ioctl_code)) > 0) { if ((size = _IOC_SIZE (ctrl.ioctl_code)) > 0) {
if ((buf = kmalloc (size, GFP_KERNEL)) == 0) if ((buf = kmalloc (size, GFP_KERNEL)) == 0)
...@@ -1173,19 +1173,19 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd ...@@ -1173,19 +1173,19 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
} }
switch (cmd) { switch (cmd) {
case USBDEVFS_CONTROL: case USBDEVFS_CONTROL:
ret = proc_control(ps, (void *)arg); ret = proc_control(ps, (void __user *)arg);
if (ret >= 0) if (ret >= 0)
inode->i_mtime = CURRENT_TIME; inode->i_mtime = CURRENT_TIME;
break; break;
case USBDEVFS_BULK: case USBDEVFS_BULK:
ret = proc_bulk(ps, (void *)arg); ret = proc_bulk(ps, (void __user *)arg);
if (ret >= 0) if (ret >= 0)
inode->i_mtime = CURRENT_TIME; inode->i_mtime = CURRENT_TIME;
break; break;
case USBDEVFS_RESETEP: case USBDEVFS_RESETEP:
ret = proc_resetep(ps, (void *)arg); ret = proc_resetep(ps, (void __user *)arg);
if (ret >= 0) if (ret >= 0)
inode->i_mtime = CURRENT_TIME; inode->i_mtime = CURRENT_TIME;
break; break;
...@@ -1195,59 +1195,59 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd ...@@ -1195,59 +1195,59 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break; break;
case USBDEVFS_CLEAR_HALT: case USBDEVFS_CLEAR_HALT:
ret = proc_clearhalt(ps, (void *)arg); ret = proc_clearhalt(ps, (void __user *)arg);
if (ret >= 0) if (ret >= 0)
inode->i_mtime = CURRENT_TIME; inode->i_mtime = CURRENT_TIME;
break; break;
case USBDEVFS_GETDRIVER: case USBDEVFS_GETDRIVER:
ret = proc_getdriver(ps, (void *)arg); ret = proc_getdriver(ps, (void __user *)arg);
break; break;
case USBDEVFS_CONNECTINFO: case USBDEVFS_CONNECTINFO:
ret = proc_connectinfo(ps, (void *)arg); ret = proc_connectinfo(ps, (void __user *)arg);
break; break;
case USBDEVFS_SETINTERFACE: case USBDEVFS_SETINTERFACE:
ret = proc_setintf(ps, (void *)arg); ret = proc_setintf(ps, (void __user *)arg);
break; break;
case USBDEVFS_SETCONFIGURATION: case USBDEVFS_SETCONFIGURATION:
ret = proc_setconfig(ps, (void *)arg); ret = proc_setconfig(ps, (void __user *)arg);
break; break;
case USBDEVFS_SUBMITURB: case USBDEVFS_SUBMITURB:
ret = proc_submiturb(ps, (void *)arg); ret = proc_submiturb(ps, (void __user *)arg);
if (ret >= 0) if (ret >= 0)
inode->i_mtime = CURRENT_TIME; inode->i_mtime = CURRENT_TIME;
break; break;
case USBDEVFS_DISCARDURB: case USBDEVFS_DISCARDURB:
ret = proc_unlinkurb(ps, (void *)arg); ret = proc_unlinkurb(ps, (void __user *)arg);
break; break;
case USBDEVFS_REAPURB: case USBDEVFS_REAPURB:
ret = proc_reapurb(ps, (void *)arg); ret = proc_reapurb(ps, (void __user *)arg);
break; break;
case USBDEVFS_REAPURBNDELAY: case USBDEVFS_REAPURBNDELAY:
ret = proc_reapurbnonblock(ps, (void *)arg); ret = proc_reapurbnonblock(ps, (void __user *)arg);
break; break;
case USBDEVFS_DISCSIGNAL: case USBDEVFS_DISCSIGNAL:
ret = proc_disconnectsignal(ps, (void *)arg); ret = proc_disconnectsignal(ps, (void __user *)arg);
break; break;
case USBDEVFS_CLAIMINTERFACE: case USBDEVFS_CLAIMINTERFACE:
ret = proc_claiminterface(ps, (void *)arg); ret = proc_claiminterface(ps, (void __user *)arg);
break; break;
case USBDEVFS_RELEASEINTERFACE: case USBDEVFS_RELEASEINTERFACE:
ret = proc_releaseinterface(ps, (void *)arg); ret = proc_releaseinterface(ps, (void __user *)arg);
break; break;
case USBDEVFS_IOCTL: case USBDEVFS_IOCTL:
ret = proc_ioctl(ps, (void *) arg); ret = proc_ioctl(ps, (void __user *) arg);
break; break;
} }
up_read(&ps->devsem); up_read(&ps->devsem);
......
...@@ -46,14 +46,14 @@ struct usbdevfs_ctrltransfer { ...@@ -46,14 +46,14 @@ struct usbdevfs_ctrltransfer {
__u16 wIndex; __u16 wIndex;
__u16 wLength; __u16 wLength;
__u32 timeout; /* in milliseconds */ __u32 timeout; /* in milliseconds */
void *data; void __user *data;
}; };
struct usbdevfs_bulktransfer { struct usbdevfs_bulktransfer {
unsigned int ep; unsigned int ep;
unsigned int len; unsigned int len;
unsigned int timeout; /* in milliseconds */ unsigned int timeout; /* in milliseconds */
void *data; void __user *data;
}; };
struct usbdevfs_setinterface { struct usbdevfs_setinterface {
...@@ -97,7 +97,7 @@ struct usbdevfs_urb { ...@@ -97,7 +97,7 @@ struct usbdevfs_urb {
unsigned char endpoint; unsigned char endpoint;
int status; int status;
unsigned int flags; unsigned int flags;
void *buffer; void __user *buffer;
int buffer_length; int buffer_length;
int actual_length; int actual_length;
int start_frame; int start_frame;
...@@ -113,7 +113,7 @@ struct usbdevfs_ioctl { ...@@ -113,7 +113,7 @@ struct usbdevfs_ioctl {
int ifno; /* interface 0..N ; negative numbers reserved */ int ifno; /* interface 0..N ; negative numbers reserved */
int ioctl_code; /* MUST encode size + direction of data so the int ioctl_code; /* MUST encode size + direction of data so the
* macros in <asm/ioctl.h> give correct values */ * macros in <asm/ioctl.h> give correct values */
void *data; /* param buffer (in, or out) */ void __user *data; /* param buffer (in, or out) */
}; };
/* You can do most things with hubs just through control messages, /* You can do most things with hubs just through control messages,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment