Commit 796c43e5 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: ppdev annotation

parent 138b97b6
...@@ -103,7 +103,7 @@ static inline void pp_enable_irq (struct pp_struct *pp) ...@@ -103,7 +103,7 @@ static inline void pp_enable_irq (struct pp_struct *pp)
port->ops->enable_irq (port); port->ops->enable_irq (port);
} }
static ssize_t pp_read (struct file * file, char * buf, size_t count, static ssize_t pp_read (struct file * file, char __user * buf, size_t count,
loff_t * ppos) loff_t * ppos)
{ {
unsigned int minor = iminor(file->f_dentry->d_inode); unsigned int minor = iminor(file->f_dentry->d_inode);
...@@ -186,8 +186,8 @@ static ssize_t pp_read (struct file * file, char * buf, size_t count, ...@@ -186,8 +186,8 @@ static ssize_t pp_read (struct file * file, char * buf, size_t count,
return bytes_read; return bytes_read;
} }
static ssize_t pp_write (struct file * file, const char * buf, size_t count, static ssize_t pp_write (struct file * file, const char __user * buf,
loff_t * ppos) size_t count, loff_t * ppos)
{ {
unsigned int minor = iminor(file->f_dentry->d_inode); unsigned int minor = iminor(file->f_dentry->d_inode);
struct pp_struct *pp = file->private_data; struct pp_struct *pp = file->private_data;
...@@ -335,6 +335,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -335,6 +335,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
unsigned int minor = iminor(inode); unsigned int minor = iminor(inode);
struct pp_struct *pp = file->private_data; struct pp_struct *pp = file->private_data;
struct parport * port; struct parport * port;
void __user *argp = (void __user *)arg;
/* First handle the cases that don't take arguments. */ /* First handle the cases that don't take arguments. */
switch (cmd) { switch (cmd) {
...@@ -396,7 +397,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -396,7 +397,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
case PPSETMODE: case PPSETMODE:
{ {
int mode; int mode;
if (copy_from_user (&mode, (int *) arg, sizeof (mode))) if (copy_from_user (&mode, argp, sizeof (mode)))
return -EFAULT; return -EFAULT;
/* FIXME: validate mode */ /* FIXME: validate mode */
pp->state.mode = mode; pp->state.mode = mode;
...@@ -418,7 +419,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -418,7 +419,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
} else { } else {
mode = pp->state.mode; mode = pp->state.mode;
} }
if (copy_to_user ((int *)arg, &mode, sizeof (mode))) { if (copy_to_user (argp, &mode, sizeof (mode))) {
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -426,7 +427,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -426,7 +427,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
case PPSETPHASE: case PPSETPHASE:
{ {
int phase; int phase;
if (copy_from_user (&phase, (int *) arg, sizeof (phase))) { if (copy_from_user (&phase, argp, sizeof (phase))) {
return -EFAULT; return -EFAULT;
} }
/* FIXME: validate phase */ /* FIXME: validate phase */
...@@ -447,7 +448,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -447,7 +448,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
} else { } else {
phase = pp->state.phase; phase = pp->state.phase;
} }
if (copy_to_user ((int *)arg, &phase, sizeof (phase))) { if (copy_to_user (argp, &phase, sizeof (phase))) {
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -461,7 +462,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -461,7 +462,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
return -ENODEV; return -ENODEV;
modes = port->modes; modes = port->modes;
if (copy_to_user ((unsigned int *)arg, &modes, sizeof (modes))) { if (copy_to_user (argp, &modes, sizeof (modes))) {
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -470,7 +471,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -470,7 +471,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
{ {
int uflags; int uflags;
if (copy_from_user (&uflags, (int *)arg, sizeof (uflags))) { if (copy_from_user (&uflags, argp, sizeof (uflags))) {
return -EFAULT; return -EFAULT;
} }
pp->flags &= ~PP_FLAGMASK; pp->flags &= ~PP_FLAGMASK;
...@@ -482,7 +483,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -482,7 +483,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
int uflags; int uflags;
uflags = pp->flags & PP_FLAGMASK; uflags = pp->flags & PP_FLAGMASK;
if (copy_to_user ((int *)arg, &uflags, sizeof (uflags))) { if (copy_to_user (argp, &uflags, sizeof (uflags))) {
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -509,17 +510,17 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -509,17 +510,17 @@ static int pp_ioctl(struct inode *inode, struct file *file,
case PPRSTATUS: case PPRSTATUS:
reg = parport_read_status (port); reg = parport_read_status (port);
if (copy_to_user ((unsigned char *) arg, &reg, sizeof (reg))) if (copy_to_user (argp, &reg, sizeof (reg)))
return -EFAULT; return -EFAULT;
return 0; return 0;
case PPRDATA: case PPRDATA:
reg = parport_read_data (port); reg = parport_read_data (port);
if (copy_to_user ((unsigned char *) arg, &reg, sizeof (reg))) if (copy_to_user (argp, &reg, sizeof (reg)))
return -EFAULT; return -EFAULT;
return 0; return 0;
case PPRCONTROL: case PPRCONTROL:
reg = parport_read_control (port); reg = parport_read_control (port);
if (copy_to_user ((unsigned char *) arg, &reg, sizeof (reg))) if (copy_to_user (argp, &reg, sizeof (reg)))
return -EFAULT; return -EFAULT;
return 0; return 0;
case PPYIELD: case PPYIELD:
...@@ -538,29 +539,29 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -538,29 +539,29 @@ static int pp_ioctl(struct inode *inode, struct file *file,
return 0; return 0;
case PPWCONTROL: case PPWCONTROL:
if (copy_from_user (&reg, (unsigned char *) arg, sizeof (reg))) if (copy_from_user (&reg, argp, sizeof (reg)))
return -EFAULT; return -EFAULT;
parport_write_control (port, reg); parport_write_control (port, reg);
return 0; return 0;
case PPWDATA: case PPWDATA:
if (copy_from_user (&reg, (unsigned char *) arg, sizeof (reg))) if (copy_from_user (&reg, argp, sizeof (reg)))
return -EFAULT; return -EFAULT;
parport_write_data (port, reg); parport_write_data (port, reg);
return 0; return 0;
case PPFCONTROL: case PPFCONTROL:
if (copy_from_user (&mask, (unsigned char *) arg, if (copy_from_user (&mask, argp,
sizeof (mask))) sizeof (mask)))
return -EFAULT; return -EFAULT;
if (copy_from_user (&reg, 1 + (unsigned char *) arg, if (copy_from_user (&reg, 1 + (unsigned char __user *) arg,
sizeof (reg))) sizeof (reg)))
return -EFAULT; return -EFAULT;
parport_frob_control (port, mask, reg); parport_frob_control (port, mask, reg);
return 0; return 0;
case PPDATADIR: case PPDATADIR:
if (copy_from_user (&mode, (int *) arg, sizeof (mode))) if (copy_from_user (&mode, argp, sizeof (mode)))
return -EFAULT; return -EFAULT;
if (mode) if (mode)
port->ops->data_reverse (port); port->ops->data_reverse (port);
...@@ -569,7 +570,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -569,7 +570,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
return 0; return 0;
case PPNEGOT: case PPNEGOT:
if (copy_from_user (&mode, (int *) arg, sizeof (mode))) if (copy_from_user (&mode, argp, sizeof (mode)))
return -EFAULT; return -EFAULT;
switch ((ret = parport_negotiate (port, mode))) { switch ((ret = parport_negotiate (port, mode))) {
case 0: break; case 0: break;
...@@ -584,8 +585,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -584,8 +585,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
return ret; return ret;
case PPWCTLONIRQ: case PPWCTLONIRQ:
if (copy_from_user (&reg, (unsigned char *) arg, if (copy_from_user (&reg, argp, sizeof (reg)))
sizeof (reg)))
return -EFAULT; return -EFAULT;
/* Remember what to set the control lines to, for next /* Remember what to set the control lines to, for next
...@@ -596,14 +596,13 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -596,14 +596,13 @@ static int pp_ioctl(struct inode *inode, struct file *file,
case PPCLRIRQ: case PPCLRIRQ:
ret = atomic_read (&pp->irqc); ret = atomic_read (&pp->irqc);
if (copy_to_user ((int *) arg, &ret, sizeof (ret))) if (copy_to_user (argp, &ret, sizeof (ret)))
return -EFAULT; return -EFAULT;
atomic_sub (ret, &pp->irqc); atomic_sub (ret, &pp->irqc);
return 0; return 0;
case PPSETTIME: case PPSETTIME:
if (copy_from_user (&par_timeout, (struct timeval *)arg, if (copy_from_user (&par_timeout, argp, sizeof(struct timeval))) {
sizeof(struct timeval))) {
return -EFAULT; return -EFAULT;
} }
/* Convert to jiffies, place in pp->pdev->timeout */ /* Convert to jiffies, place in pp->pdev->timeout */
...@@ -622,10 +621,8 @@ static int pp_ioctl(struct inode *inode, struct file *file, ...@@ -622,10 +621,8 @@ static int pp_ioctl(struct inode *inode, struct file *file,
to_jiffies = pp->pdev->timeout; to_jiffies = pp->pdev->timeout;
par_timeout.tv_sec = to_jiffies / HZ; par_timeout.tv_sec = to_jiffies / HZ;
par_timeout.tv_usec = (to_jiffies % (long)HZ) * (1000000/HZ); par_timeout.tv_usec = (to_jiffies % (long)HZ) * (1000000/HZ);
if (copy_to_user ((struct timeval *)arg, &par_timeout, if (copy_to_user (argp, &par_timeout, sizeof(struct timeval)))
sizeof(struct timeval))) {
return -EFAULT; return -EFAULT;
}
return 0; return 0;
default: default:
......
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