| .. | .. |
|---|
| 220 | 220 | u8 bDataCounter; |
|---|
| 221 | 221 | __be16 wBaseAddrHi; |
|---|
| 222 | 222 | __be16 wBaseAddrLo; |
|---|
| 223 | | - u8 bData[0]; |
|---|
| 223 | + u8 bData[]; |
|---|
| 224 | 224 | } __packed; |
|---|
| 225 | 225 | |
|---|
| 226 | 226 | struct ti_read_data_request { |
|---|
| .. | .. |
|---|
| 235 | 235 | __u8 bCmdCode; |
|---|
| 236 | 236 | __u8 bModuleId; |
|---|
| 237 | 237 | __u8 bErrorCode; |
|---|
| 238 | | - __u8 bData[0]; |
|---|
| 238 | + __u8 bData[]; |
|---|
| 239 | 239 | } __packed; |
|---|
| 240 | 240 | |
|---|
| 241 | 241 | /* Interrupt struct */ |
|---|
| .. | .. |
|---|
| 314 | 314 | static bool ti_tx_empty(struct usb_serial_port *port); |
|---|
| 315 | 315 | static void ti_throttle(struct tty_struct *tty); |
|---|
| 316 | 316 | static void ti_unthrottle(struct tty_struct *tty); |
|---|
| 317 | | -static int ti_ioctl(struct tty_struct *tty, |
|---|
| 318 | | - unsigned int cmd, unsigned long arg); |
|---|
| 319 | 317 | static void ti_set_termios(struct tty_struct *tty, |
|---|
| 320 | 318 | struct usb_serial_port *port, struct ktermios *old_termios); |
|---|
| 321 | 319 | static int ti_tiocmget(struct tty_struct *tty); |
|---|
| .. | .. |
|---|
| 331 | 329 | static void ti_send(struct ti_port *tport); |
|---|
| 332 | 330 | static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); |
|---|
| 333 | 331 | static int ti_get_lsr(struct ti_port *tport, u8 *lsr); |
|---|
| 334 | | -static int ti_get_serial_info(struct ti_port *tport, |
|---|
| 335 | | - struct serial_struct __user *ret_arg); |
|---|
| 336 | | -static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, |
|---|
| 337 | | - struct serial_struct __user *new_arg); |
|---|
| 332 | +static int ti_get_serial_info(struct tty_struct *tty, |
|---|
| 333 | + struct serial_struct *ss); |
|---|
| 334 | +static int ti_set_serial_info(struct tty_struct *tty, |
|---|
| 335 | + struct serial_struct *ss); |
|---|
| 338 | 336 | static void ti_handle_new_msr(struct ti_port *tport, u8 msr); |
|---|
| 339 | 337 | |
|---|
| 340 | 338 | static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty); |
|---|
| .. | .. |
|---|
| 439 | 437 | .tx_empty = ti_tx_empty, |
|---|
| 440 | 438 | .throttle = ti_throttle, |
|---|
| 441 | 439 | .unthrottle = ti_unthrottle, |
|---|
| 442 | | - .ioctl = ti_ioctl, |
|---|
| 440 | + .get_serial = ti_get_serial_info, |
|---|
| 441 | + .set_serial = ti_set_serial_info, |
|---|
| 443 | 442 | .set_termios = ti_set_termios, |
|---|
| 444 | 443 | .tiocmget = ti_tiocmget, |
|---|
| 445 | 444 | .tiocmset = ti_tiocmset, |
|---|
| .. | .. |
|---|
| 472 | 471 | .tx_empty = ti_tx_empty, |
|---|
| 473 | 472 | .throttle = ti_throttle, |
|---|
| 474 | 473 | .unthrottle = ti_unthrottle, |
|---|
| 475 | | - .ioctl = ti_ioctl, |
|---|
| 474 | + .get_serial = ti_get_serial_info, |
|---|
| 475 | + .set_serial = ti_set_serial_info, |
|---|
| 476 | 476 | .set_termios = ti_set_termios, |
|---|
| 477 | 477 | .tiocmget = ti_tiocmget, |
|---|
| 478 | 478 | .tiocmset = ti_tiocmset, |
|---|
| .. | .. |
|---|
| 803 | 803 | , __func__, status); |
|---|
| 804 | 804 | |
|---|
| 805 | 805 | mutex_lock(&tdev->td_open_close_lock); |
|---|
| 806 | | - --tport->tp_tdev->td_open_port_count; |
|---|
| 807 | | - if (tport->tp_tdev->td_open_port_count == 0) { |
|---|
| 806 | + --tdev->td_open_port_count; |
|---|
| 807 | + if (tdev->td_open_port_count == 0) { |
|---|
| 808 | 808 | /* last port is closed, shut down interrupt urb */ |
|---|
| 809 | 809 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
|---|
| 810 | 810 | } |
|---|
| .. | .. |
|---|
| 900 | 900 | __func__, status); |
|---|
| 901 | 901 | } |
|---|
| 902 | 902 | } |
|---|
| 903 | | - |
|---|
| 904 | | -static int ti_ioctl(struct tty_struct *tty, |
|---|
| 905 | | - unsigned int cmd, unsigned long arg) |
|---|
| 906 | | -{ |
|---|
| 907 | | - struct usb_serial_port *port = tty->driver_data; |
|---|
| 908 | | - struct ti_port *tport = usb_get_serial_port_data(port); |
|---|
| 909 | | - |
|---|
| 910 | | - switch (cmd) { |
|---|
| 911 | | - case TIOCGSERIAL: |
|---|
| 912 | | - return ti_get_serial_info(tport, |
|---|
| 913 | | - (struct serial_struct __user *)arg); |
|---|
| 914 | | - case TIOCSSERIAL: |
|---|
| 915 | | - return ti_set_serial_info(tty, tport, |
|---|
| 916 | | - (struct serial_struct __user *)arg); |
|---|
| 917 | | - } |
|---|
| 918 | | - return -ENOIOCTLCMD; |
|---|
| 919 | | -} |
|---|
| 920 | | - |
|---|
| 921 | 903 | |
|---|
| 922 | 904 | static void ti_set_termios(struct tty_struct *tty, |
|---|
| 923 | 905 | struct usb_serial_port *port, struct ktermios *old_termios) |
|---|
| .. | .. |
|---|
| 1416 | 1398 | } |
|---|
| 1417 | 1399 | |
|---|
| 1418 | 1400 | |
|---|
| 1419 | | -static int ti_get_serial_info(struct ti_port *tport, |
|---|
| 1420 | | - struct serial_struct __user *ret_arg) |
|---|
| 1401 | +static int ti_get_serial_info(struct tty_struct *tty, |
|---|
| 1402 | + struct serial_struct *ss) |
|---|
| 1421 | 1403 | { |
|---|
| 1422 | | - struct usb_serial_port *port = tport->tp_port; |
|---|
| 1423 | | - struct serial_struct ret_serial; |
|---|
| 1404 | + struct usb_serial_port *port = tty->driver_data; |
|---|
| 1405 | + struct ti_port *tport = usb_get_serial_port_data(port); |
|---|
| 1424 | 1406 | unsigned cwait; |
|---|
| 1425 | 1407 | |
|---|
| 1426 | 1408 | cwait = port->port.closing_wait; |
|---|
| 1427 | 1409 | if (cwait != ASYNC_CLOSING_WAIT_NONE) |
|---|
| 1428 | 1410 | cwait = jiffies_to_msecs(cwait) / 10; |
|---|
| 1429 | 1411 | |
|---|
| 1430 | | - memset(&ret_serial, 0, sizeof(ret_serial)); |
|---|
| 1431 | | - |
|---|
| 1432 | | - ret_serial.type = PORT_16550A; |
|---|
| 1433 | | - ret_serial.line = port->minor; |
|---|
| 1434 | | - ret_serial.port = port->port_number; |
|---|
| 1435 | | - ret_serial.xmit_fifo_size = kfifo_size(&port->write_fifo); |
|---|
| 1436 | | - ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; |
|---|
| 1437 | | - ret_serial.closing_wait = cwait; |
|---|
| 1438 | | - |
|---|
| 1439 | | - if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg))) |
|---|
| 1440 | | - return -EFAULT; |
|---|
| 1441 | | - |
|---|
| 1412 | + ss->type = PORT_16550A; |
|---|
| 1413 | + ss->line = port->minor; |
|---|
| 1414 | + ss->port = port->port_number; |
|---|
| 1415 | + ss->xmit_fifo_size = kfifo_size(&port->write_fifo); |
|---|
| 1416 | + ss->baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; |
|---|
| 1417 | + ss->closing_wait = cwait; |
|---|
| 1442 | 1418 | return 0; |
|---|
| 1443 | 1419 | } |
|---|
| 1444 | 1420 | |
|---|
| 1445 | 1421 | |
|---|
| 1446 | | -static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, |
|---|
| 1447 | | - struct serial_struct __user *new_arg) |
|---|
| 1422 | +static int ti_set_serial_info(struct tty_struct *tty, |
|---|
| 1423 | + struct serial_struct *ss) |
|---|
| 1448 | 1424 | { |
|---|
| 1449 | | - struct serial_struct new_serial; |
|---|
| 1425 | + struct usb_serial_port *port = tty->driver_data; |
|---|
| 1426 | + struct tty_port *tport = &port->port; |
|---|
| 1450 | 1427 | unsigned cwait; |
|---|
| 1451 | 1428 | |
|---|
| 1452 | | - if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) |
|---|
| 1453 | | - return -EFAULT; |
|---|
| 1454 | | - |
|---|
| 1455 | | - cwait = new_serial.closing_wait; |
|---|
| 1429 | + cwait = ss->closing_wait; |
|---|
| 1456 | 1430 | if (cwait != ASYNC_CLOSING_WAIT_NONE) |
|---|
| 1457 | | - cwait = msecs_to_jiffies(10 * new_serial.closing_wait); |
|---|
| 1431 | + cwait = msecs_to_jiffies(10 * ss->closing_wait); |
|---|
| 1458 | 1432 | |
|---|
| 1459 | | - tport->tp_port->port.closing_wait = cwait; |
|---|
| 1433 | + if (!capable(CAP_SYS_ADMIN)) { |
|---|
| 1434 | + if (cwait != tport->closing_wait) |
|---|
| 1435 | + return -EPERM; |
|---|
| 1436 | + } |
|---|
| 1437 | + |
|---|
| 1438 | + tport->closing_wait = cwait; |
|---|
| 1460 | 1439 | |
|---|
| 1461 | 1440 | return 0; |
|---|
| 1462 | 1441 | } |
|---|