aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-09-11 23:42:36 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-10-13 00:50:37 -0400
commit3ae36bed3a93f5b871341be9b2e39aaff0d2559f (patch)
treed85e64c49c1465e136f92ab606964ae3cfedda0d
parentc8f97e77d53ff0717a1175b3cdefa497127347f9 (diff)
fdti_sio: switch to ->[sg]et_serial()
Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/usb/serial/ftdi_sio.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b5cef322826f..758ba789e997 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1055,6 +1055,10 @@ static int ftdi_tiocmset(struct tty_struct *tty,
1055 unsigned int set, unsigned int clear); 1055 unsigned int set, unsigned int clear);
1056static int ftdi_ioctl(struct tty_struct *tty, 1056static int ftdi_ioctl(struct tty_struct *tty,
1057 unsigned int cmd, unsigned long arg); 1057 unsigned int cmd, unsigned long arg);
1058static int get_serial_info(struct tty_struct *tty,
1059 struct serial_struct *ss);
1060static int set_serial_info(struct tty_struct *tty,
1061 struct serial_struct *ss);
1058static void ftdi_break_ctl(struct tty_struct *tty, int break_state); 1062static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
1059static bool ftdi_tx_empty(struct usb_serial_port *port); 1063static bool ftdi_tx_empty(struct usb_serial_port *port);
1060static int ftdi_get_modem_status(struct usb_serial_port *port, 1064static int ftdi_get_modem_status(struct usb_serial_port *port,
@@ -1091,6 +1095,8 @@ static struct usb_serial_driver ftdi_sio_device = {
1091 .tiocmiwait = usb_serial_generic_tiocmiwait, 1095 .tiocmiwait = usb_serial_generic_tiocmiwait,
1092 .get_icount = usb_serial_generic_get_icount, 1096 .get_icount = usb_serial_generic_get_icount,
1093 .ioctl = ftdi_ioctl, 1097 .ioctl = ftdi_ioctl,
1098 .get_serial = get_serial_info,
1099 .set_serial = set_serial_info,
1094 .set_termios = ftdi_set_termios, 1100 .set_termios = ftdi_set_termios,
1095 .break_ctl = ftdi_break_ctl, 1101 .break_ctl = ftdi_break_ctl,
1096 .tx_empty = ftdi_tx_empty, 1102 .tx_empty = ftdi_tx_empty,
@@ -1443,48 +1449,42 @@ static int read_latency_timer(struct usb_serial_port *port)
1443 return 0; 1449 return 0;
1444} 1450}
1445 1451
1446static int get_serial_info(struct usb_serial_port *port, 1452static int get_serial_info(struct tty_struct *tty,
1447 struct serial_struct __user *retinfo) 1453 struct serial_struct *ss)
1448{ 1454{
1455 struct usb_serial_port *port = tty->driver_data;
1449 struct ftdi_private *priv = usb_get_serial_port_data(port); 1456 struct ftdi_private *priv = usb_get_serial_port_data(port);
1450 struct serial_struct tmp;
1451 1457
1452 memset(&tmp, 0, sizeof(tmp)); 1458 ss->flags = priv->flags;
1453 tmp.flags = priv->flags; 1459 ss->baud_base = priv->baud_base;
1454 tmp.baud_base = priv->baud_base; 1460 ss->custom_divisor = priv->custom_divisor;
1455 tmp.custom_divisor = priv->custom_divisor;
1456 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1457 return -EFAULT;
1458 return 0; 1461 return 0;
1459} 1462}
1460 1463
1461static int set_serial_info(struct tty_struct *tty, 1464static int set_serial_info(struct tty_struct *tty,
1462 struct usb_serial_port *port, struct serial_struct __user *newinfo) 1465 struct serial_struct *ss)
1463{ 1466{
1467 struct usb_serial_port *port = tty->driver_data;
1464 struct ftdi_private *priv = usb_get_serial_port_data(port); 1468 struct ftdi_private *priv = usb_get_serial_port_data(port);
1465 struct serial_struct new_serial;
1466 struct ftdi_private old_priv; 1469 struct ftdi_private old_priv;
1467 1470
1468 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1469 return -EFAULT;
1470
1471 mutex_lock(&priv->cfg_lock); 1471 mutex_lock(&priv->cfg_lock);
1472 old_priv = *priv; 1472 old_priv = *priv;
1473 1473
1474 /* Do error checking and permission checking */ 1474 /* Do error checking and permission checking */
1475 1475
1476 if (!capable(CAP_SYS_ADMIN)) { 1476 if (!capable(CAP_SYS_ADMIN)) {
1477 if ((new_serial.flags ^ priv->flags) & ~ASYNC_USR_MASK) { 1477 if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) {
1478 mutex_unlock(&priv->cfg_lock); 1478 mutex_unlock(&priv->cfg_lock);
1479 return -EPERM; 1479 return -EPERM;
1480 } 1480 }
1481 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1481 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
1482 (new_serial.flags & ASYNC_USR_MASK)); 1482 (ss->flags & ASYNC_USR_MASK));
1483 priv->custom_divisor = new_serial.custom_divisor; 1483 priv->custom_divisor = ss->custom_divisor;
1484 goto check_and_exit; 1484 goto check_and_exit;
1485 } 1485 }
1486 1486
1487 if (new_serial.baud_base != priv->baud_base) { 1487 if (ss->baud_base != priv->baud_base) {
1488 mutex_unlock(&priv->cfg_lock); 1488 mutex_unlock(&priv->cfg_lock);
1489 return -EINVAL; 1489 return -EINVAL;
1490 } 1490 }
@@ -1492,8 +1492,8 @@ static int set_serial_info(struct tty_struct *tty,
1492 /* Make the changes - these are privileged changes! */ 1492 /* Make the changes - these are privileged changes! */
1493 1493
1494 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 1494 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
1495 (new_serial.flags & ASYNC_FLAGS)); 1495 (ss->flags & ASYNC_FLAGS));
1496 priv->custom_divisor = new_serial.custom_divisor; 1496 priv->custom_divisor = ss->custom_divisor;
1497 1497
1498check_and_exit: 1498check_and_exit:
1499 write_latency_timer(port); 1499 write_latency_timer(port);
@@ -1507,10 +1507,8 @@ check_and_exit:
1507 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); 1507 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n");
1508 1508
1509 change_speed(tty, port); 1509 change_speed(tty, port);
1510 mutex_unlock(&priv->cfg_lock);
1511 } 1510 }
1512 else 1511 mutex_unlock(&priv->cfg_lock);
1513 mutex_unlock(&priv->cfg_lock);
1514 return 0; 1512 return 0;
1515} 1513}
1516 1514
@@ -2452,10 +2450,6 @@ static int ftdi_ioctl(struct tty_struct *tty,
2452 void __user *argp = (void __user *)arg; 2450 void __user *argp = (void __user *)arg;
2453 2451
2454 switch (cmd) { 2452 switch (cmd) {
2455 case TIOCGSERIAL:
2456 return get_serial_info(port, argp);
2457 case TIOCSSERIAL:
2458 return set_serial_info(tty, port, argp);
2459 case TIOCSERGETLSR: 2453 case TIOCSERGETLSR:
2460 return get_lsr_info(port, argp); 2454 return get_lsr_info(port, argp);
2461 default: 2455 default: