Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338672
b: refs/heads/master
c: ba2d8ce
h: refs/heads/master
v: v3
  • Loading branch information
Dan Williams authored and Greg Kroah-Hartman committed Nov 16, 2012
1 parent 870510e commit b2cd64a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 73050d7144272f2485e22685fb266c9a6c2eb2d6
refs/heads/master: ba2d8ce9db0a61505362bb17b8899df3d3326146
38 changes: 38 additions & 0 deletions trunk/drivers/usb/class/cdc-acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,48 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
tmp.flags = ASYNC_LOW_LATENCY;
tmp.xmit_fifo_size = acm->writesize;
tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
tmp.close_delay = acm->port.close_delay / 10;
tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE :
acm->port.closing_wait / 10;

if (copy_to_user(info, &tmp, sizeof(tmp)))
return -EFAULT;
else
return 0;
}

static int set_serial_info(struct acm *acm,
struct serial_struct __user *newinfo)
{
struct serial_struct new_serial;
unsigned int closing_wait, close_delay;
int retval = 0;

if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
return -EFAULT;

close_delay = new_serial.close_delay * 10;
closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;

mutex_lock(&acm->port.mutex);

if (!capable(CAP_SYS_ADMIN)) {
if ((close_delay != acm->port.close_delay) ||
(closing_wait != acm->port.closing_wait))
retval = -EPERM;
else
retval = -EOPNOTSUPP;
} else {
acm->port.close_delay = close_delay;
acm->port.closing_wait = closing_wait;
}

mutex_unlock(&acm->port.mutex);
return retval;
}

static int acm_tty_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
Expand All @@ -804,6 +839,9 @@ static int acm_tty_ioctl(struct tty_struct *tty,
case TIOCGSERIAL: /* gets serial port data */
rv = get_serial_info(acm, (struct serial_struct __user *) arg);
break;
case TIOCSSERIAL:
rv = set_serial_info(acm, (struct serial_struct __user *) arg);
break;
}

return rv;
Expand Down

0 comments on commit b2cd64a

Please sign in to comment.