diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-24 14:43:41 +0100 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-24 14:43:41 +0100 |
| commit | 44adbac8f7217040be97928cd19998259d9d4418 (patch) | |
| tree | c1c6ac9aa4d47801dc9133d6d641286631a8f4b4 /drivers/usb/serial | |
| parent | 08ffb584d9eb17940321317ef6c9c7383ad4f149 (diff) | |
| parent | ce5a983191ce466cbe35e240ac09e28cca3e50c9 (diff) | |
| download | linux-44adbac8f7217040be97928cd19998259d9d4418.tar.gz linux-44adbac8f7217040be97928cd19998259d9d4418.tar.bz2 linux-44adbac8f7217040be97928cd19998259d9d4418.zip | |
Merge branch 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull tty ioctl updates from Al Viro:
"This is the compat_ioctl work related to tty ioctls.
Quite a bit of dead code taken out, all tty-related stuff gone from
fs/compat_ioctl.c. A bunch of compat bugs fixed - some still remain,
but all more or less generic tty-related ioctls should be covered
(remaining issues are in things like driver-private ioctls in a pcmcia
serial card driver not getting properly handled in 32bit processes on
64bit host, etc)"
* 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (53 commits)
kill TIOCSERGSTRUCT
change semantics of ldisc ->compat_ioctl()
kill TIOCSER[SG]WILD
synclink_gt(): fix compat_ioctl()
pty: fix compat ioctls
compat_ioctl - kill keyboard ioctl handling
gigaset: add ->compat_ioctl()
vt_compat_ioctl(): clean up, use compat_ptr() properly
gigaset: don't try to printk userland buffer contents
dgnc: don't bother with (empty) stub for TCXONC
dgnc: leave TIOC[GS]SOFTCAR to ldisc
remove fallback to drivers for TIOCGICOUNT
dgnc: break-related ioctls won't reach ->ioctl()
kill the rest of tty COMPAT_IOCTL() entries
dgnc: TIOCM... won't reach ->ioctl()
isdn_tty: TCSBRK{,P} won't reach ->ioctl()
kill capinc_tty_ioctl()
take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
synclink: reduce pointless checks in ->ioctl()
complete ->[sg]et_serial() switchover
...
Diffstat (limited to 'drivers/usb/serial')
| -rw-r--r-- | drivers/usb/serial/ark3116.c | 38 | ||||
| -rw-r--r-- | drivers/usb/serial/f81232.c | 36 | ||||
| -rw-r--r-- | drivers/usb/serial/f81534.c | 38 | ||||
| -rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 48 | ||||
| -rw-r--r-- | drivers/usb/serial/io_edgeport.c | 37 | ||||
| -rw-r--r-- | drivers/usb/serial/io_ti.c | 47 | ||||
| -rw-r--r-- | drivers/usb/serial/mos7720.c | 86 | ||||
| -rw-r--r-- | drivers/usb/serial/mos7840.c | 39 | ||||
| -rw-r--r-- | drivers/usb/serial/opticon.c | 43 | ||||
| -rw-r--r-- | drivers/usb/serial/option.c | 3 | ||||
| -rw-r--r-- | drivers/usb/serial/pl2303.c | 29 | ||||
| -rw-r--r-- | drivers/usb/serial/quatech2.c | 42 | ||||
| -rw-r--r-- | drivers/usb/serial/ssu100.c | 42 | ||||
| -rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 74 | ||||
| -rw-r--r-- | drivers/usb/serial/usb-serial.c | 20 | ||||
| -rw-r--r-- | drivers/usb/serial/usb-wwan.h | 6 | ||||
| -rw-r--r-- | drivers/usb/serial/usb_wwan.c | 63 | ||||
| -rw-r--r-- | drivers/usb/serial/whiteheat.c | 42 |
18 files changed, 225 insertions, 508 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 7796ad8e33c6..ff38aa8963cf 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -397,38 +397,16 @@ err_free: return result; } -static int ark3116_get_serial_info(struct usb_serial_port *port, - struct serial_struct __user *retinfo) -{ - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); - - tmp.type = PORT_16654; - tmp.line = port->minor; - tmp.port = port->port_number; - tmp.baud_base = 460800; - - if (copy_to_user(retinfo, &tmp, sizeof(tmp))) - return -EFAULT; - - return 0; -} - -static int ark3116_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) +static int ark3116_get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - void __user *user_arg = (void __user *)arg; - - switch (cmd) { - case TIOCGSERIAL: - return ark3116_get_serial_info(port, user_arg); - default: - break; - } - return -ENOIOCTLCMD; + ss->type = PORT_16654; + ss->line = port->minor; + ss->port = port->port_number; + ss->baud_base = 460800; + return 0; } static int ark3116_tiocmget(struct tty_struct *tty) @@ -668,7 +646,7 @@ static struct usb_serial_driver ark3116_device = { .port_remove = ark3116_port_remove, .set_termios = ark3116_set_termios, .init_termios = ark3116_init_termios, - .ioctl = ark3116_ioctl, + .get_serial = ark3116_get_serial_info, .tiocmget = ark3116_tiocmget, .tiocmset = ark3116_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 96036f87b1de..0dcdcb4b2cde 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -583,36 +583,16 @@ static int f81232_carrier_raised(struct usb_serial_port *port) return 0; } -static int f81232_get_serial_info(struct usb_serial_port *port, - unsigned long arg) -{ - struct serial_struct ser; - - memset(&ser, 0, sizeof(ser)); - - ser.type = PORT_16550A; - ser.line = port->minor; - ser.port = port->port_number; - ser.baud_base = F81232_MAX_BAUDRATE; - - if (copy_to_user((void __user *)arg, &ser, sizeof(ser))) - return -EFAULT; - - return 0; -} - -static int f81232_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) +static int f81232_get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - switch (cmd) { - case TIOCGSERIAL: - return f81232_get_serial_info(port, arg); - default: - break; - } - return -ENOIOCTLCMD; + ss->type = PORT_16550A; + ss->line = port->minor; + ss->port = port->port_number; + ss->baud_base = F81232_MAX_BAUDRATE; + return 0; } static void f81232_interrupt_work(struct work_struct *work) @@ -665,7 +645,7 @@ static struct usb_serial_driver f81232_device = { .close = f81232_close, .dtr_rts = f81232_dtr_rts, .carrier_raised = f81232_carrier_raised, - .ioctl = f81232_ioctl, + .get_serial = f81232_get_serial_info, .break_ctl = f81232_break_ctl, .set_termios = f81232_set_termios, .tiocmget = f81232_tiocmget, diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 4dfbff20bda4..380933db34dd 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -1139,43 +1139,21 @@ static void f81534_close(struct usb_serial_port *port) mutex_unlock(&serial_priv->urb_mutex); } -static int f81534_get_serial_info(struct usb_serial_port *port, - struct serial_struct __user *retinfo) +static int f81534_get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { + struct usb_serial_port *port = tty->driver_data; struct f81534_port_private *port_priv; - struct serial_struct tmp; port_priv = usb_get_serial_port_data(port); - memset(&tmp, 0, sizeof(tmp)); - - tmp.type = PORT_16550A; - tmp.port = port->port_number; - tmp.line = port->minor; - tmp.baud_base = port_priv->baud_base; - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; - + ss->type = PORT_16550A; + ss->port = port->port_number; + ss->line = port->minor; + ss->baud_base = port_priv->baud_base; return 0; } -static int f81534_ioctl(struct tty_struct *tty, unsigned int cmd, - unsigned long arg) -{ - struct usb_serial_port *port = tty->driver_data; - struct serial_struct __user *buf = (struct serial_struct __user *)arg; - - switch (cmd) { - case TIOCGSERIAL: - return f81534_get_serial_info(port, buf); - default: - break; - } - - return -ENOIOCTLCMD; -} - static void f81534_process_per_serial_block(struct usb_serial_port *port, u8 *data) { @@ -1581,7 +1559,7 @@ static struct usb_serial_driver f81534_device = { .break_ctl = f81534_break_ctl, .dtr_rts = f81534_dtr_rts, .process_read_urb = f81534_process_read_urb, - .ioctl = f81534_ioctl, + .get_serial = f81534_get_serial_info, .tiocmget = f81534_tiocmget, .tiocmset = f81534_tiocmset, .write_bulk_callback = f81534_write_usb_callback, 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, unsigned int set, unsigned int clear); static int ftdi_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss); +static int set_serial_info(struct tty_struct *tty, + struct serial_struct *ss); static void ftdi_break_ctl(struct tty_struct *tty, int break_state); static bool ftdi_tx_empty(struct usb_serial_port *port); static int ftdi_get_modem_status(struct usb_serial_port *port, @@ -1091,6 +1095,8 @@ static struct usb_serial_driver ftdi_sio_device = { .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .ioctl = ftdi_ioctl, + .get_serial = get_serial_info, + .set_serial = set_serial_info, .set_termios = ftdi_set_termios, .break_ctl = ftdi_break_ctl, .tx_empty = ftdi_tx_empty, @@ -1443,48 +1449,42 @@ static int read_latency_timer(struct usb_serial_port *port) return 0; } -static int get_serial_info(struct usb_serial_port *port, - struct serial_struct __user *retinfo) +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); - struct serial_struct tmp; - memset(&tmp, 0, sizeof(tmp)); - tmp.flags = priv->flags; - tmp.baud_base = priv->baud_base; - tmp.custom_divisor = priv->custom_divisor; - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + ss->flags = priv->flags; + ss->baud_base = priv->baud_base; + ss->custom_divisor = priv->custom_divisor; return 0; } static int set_serial_info(struct tty_struct *tty, - struct usb_serial_port *port, struct serial_struct __user *newinfo) + struct serial_struct *ss) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); - struct serial_struct new_serial; struct ftdi_private old_priv; - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) - return -EFAULT; - mutex_lock(&priv->cfg_lock); old_priv = *priv; /* Do error checking and permission checking */ if (!capable(CAP_SYS_ADMIN)) { - if ((new_serial.flags ^ priv->flags) & ~ASYNC_USR_MASK) { + if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) { mutex_unlock(&priv->cfg_lock); return -EPERM; } priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | - (new_serial.flags & ASYNC_USR_MASK)); - priv->custom_divisor = new_serial.custom_divisor; + (ss->flags & ASYNC_USR_MASK)); + priv->custom_divisor = ss->custom_divisor; goto check_and_exit; } - if (new_serial.baud_base != priv->baud_base) { + if (ss->baud_base != priv->baud_base) { mutex_unlock(&priv->cfg_lock); return -EINVAL; } @@ -1492,8 +1492,8 @@ static int set_serial_info(struct tty_struct *tty, /* Make the changes - these are privileged changes! */ priv->flags = ((priv->flags & ~ASYNC_FLAGS) | - (new_serial.flags & ASYNC_FLAGS)); - priv->custom_divisor = new_serial.custom_divisor; + (ss->flags & ASYNC_FLAGS)); + priv->custom_divisor = ss->custom_divisor; check_and_exit: write_latency_timer(port); @@ -1507,10 +1507,8 @@ check_and_exit: dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); change_speed(tty, port); - mutex_unlock(&priv->cfg_lock); } - else - mutex_unlock(&priv->cfg_lock); + mutex_unlock(&priv->cfg_lock); return 0; } @@ -2452,10 +2450,6 @@ static int ftdi_ioctl(struct tty_struct *tty, void __user *argp = (void __user *)arg; switch (cmd) { - case TIOCGSERIAL: - return get_serial_info(port, argp); - case TIOCSSERIAL: - return set_serial_info(tty, port, argp); case TIOCSERGETLSR: return get_lsr_info(port, argp); default: diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 97c69d373ca6..4ca31c0e4174 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1637,24 +1637,20 @@ static int edge_tiocmget(struct tty_struct *tty) return result; } -static int get_serial_info(struct edgeport_port *edge_port, - struct serial_struct __user *retinfo) +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); - - tmp.type = PORT_16550A; - tmp.line = edge_port->port->minor; - tmp.port = edge_port->port->port_number; - tmp.irq = 0; - tmp.xmit_fifo_size = edge_port->maxTxCredits; - tmp.baud_base = 9600; - tmp.close_delay = 5*HZ; - tmp.closing_wait = 30*HZ; + struct usb_serial_port *port = tty->driver_data; + struct edgeport_port *edge_port = usb_get_serial_port_data(port); - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + ss->type = PORT_16550A; + ss->line = edge_port->port->minor; + ss->port = edge_port->port->port_number; + ss->irq = 0; + ss->xmit_fifo_size = edge_port->maxTxCredits; + ss->baud_base = 9600; + ss->close_delay = 5*HZ; + ss->closing_wait = 30*HZ; return 0; } @@ -1667,17 +1663,12 @@ static int edge_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; - DEFINE_WAIT(wait); struct edgeport_port *edge_port = usb_get_serial_port_data(port); switch (cmd) { case TIOCSERGETLSR: dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); return get_lsr_info(edge_port, (unsigned int __user *) arg); - - case TIOCGSERIAL: - dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); - return get_serial_info(edge_port, (struct serial_struct __user *) arg); } return -ENOIOCTLCMD; } @@ -3126,6 +3117,7 @@ static struct usb_serial_driver edgeport_2port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, @@ -3161,6 +3153,7 @@ static struct usb_serial_driver edgeport_4port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, @@ -3196,6 +3189,7 @@ static struct usb_serial_driver edgeport_8port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, @@ -3231,6 +3225,7 @@ static struct usb_serial_driver epic_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 6d1d6efa3055..c327d4cf7928 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2437,47 +2437,28 @@ static int edge_tiocmget(struct tty_struct *tty) return result; } -static int get_serial_info(struct edgeport_port *edge_port, - struct serial_struct __user *retinfo) +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { - struct serial_struct tmp; + struct usb_serial_port *port = tty->driver_data; + struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned cwait; cwait = edge_port->port->port.closing_wait; if (cwait != ASYNC_CLOSING_WAIT_NONE) cwait = jiffies_to_msecs(cwait) / 10; - memset(&tmp, 0, sizeof(tmp)); - - tmp.type = PORT_16550A; - tmp.line = edge_port->port->minor; - tmp.port = edge_port->port->port_number; - tmp.irq = 0; - tmp.xmit_fifo_size = edge_port->port->bulk_out_size; - tmp.baud_base = 9600; - tmp.close_delay = 5*HZ; - tmp.closing_wait = cwait; - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + ss->type = PORT_16550A; + ss->line = edge_port->port->minor; + ss->port = edge_port->port->port_number; + ss->irq = 0; + ss->xmit_fifo_size = edge_port->port->bulk_out_size; + ss->baud_base = 9600; + ss->close_delay = 5*HZ; + ss->closing_wait = cwait; return 0; } -static int edge_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) -{ - struct usb_serial_port *port = tty->driver_data; - struct edgeport_port *edge_port = usb_get_serial_port_data(port); - - switch (cmd) { - case TIOCGSERIAL: - dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__); - return get_serial_info(edge_port, - (struct serial_struct __user *) arg); - } - return -ENOIOCTLCMD; -} - static void edge_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; @@ -2738,7 +2719,7 @@ static struct usb_serial_driver edgeport_1port_device = { .release = edge_release, .port_probe = edge_port_probe, .port_remove = edge_port_remove, - .ioctl = edge_ioctl, + .get_serial = get_serial_info, .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, @@ -2777,7 +2758,7 @@ static struct usb_serial_driver edgeport_2port_device = { .release = edge_release, .port_probe = edge_port_probe, .port_remove = edge_port_remove, - .ioctl = edge_ioctl, + .get_serial = get_serial_info, .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 27109522fd8b..fc52ac75fbf6 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -1786,69 +1786,20 @@ static int mos7720_tiocmset(struct tty_struct *tty, return 0; } -static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, - unsigned int __user *value) +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { - unsigned int mcr; - unsigned int arg; - - struct usb_serial_port *port; - - if (mos7720_port == NULL) - return -1; - - port = (struct usb_serial_port *)mos7720_port->port; - mcr = mos7720_port->shadowMCR; - - if (copy_from_user(&arg, value, sizeof(int))) - return -EFAULT; - - switch (cmd) { - case TIOCMBIS: - if (arg & TIOCM_RTS) - mcr |= UART_MCR_RTS; - if (arg & TIOCM_DTR) - mcr |= UART_MCR_RTS; - if (arg & TIOCM_LOOP) - mcr |= UART_MCR_LOOP; - break; - - case TIOCMBIC: - if (arg & TIOCM_RTS) - mcr &= ~UART_MCR_RTS; - if (arg & TIOCM_DTR) - mcr &= ~UART_MCR_RTS; - if (arg & TIOCM_LOOP) - mcr &= ~UART_MCR_LOOP; - break; - - } - - mos7720_port->shadowMCR = mcr; - write_mos_reg(port->serial, port->port_number, MOS7720_MCR, - mos7720_port->shadowMCR); - - return 0; -} - -static int get_serial_info(struct moschip_port *mos7720_port, - struct serial_struct __user *retinfo) -{ - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); - - tmp.type = PORT_16550A; - tmp.line = mos7720_port->port->minor; - tmp.port = mos7720_port->port->port_number; - tmp.irq = 0; - tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; - tmp.baud_base = 9600; - tmp.close_delay = 5*HZ; - tmp.closing_wait = 30*HZ; + struct usb_serial_port *port = tty->driver_data; + struct moschip_port *mos7720_port = usb_get_serial_port_data(port); - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + ss->type = PORT_16550A; + ss->line = mos7720_port->port->minor; + ss->port = mos7720_port->port->port_number; + ss->irq = 0; + ss->xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; + ss->baud_base = 9600; + ss->close_delay = 5*HZ; + ss->closing_wait = 30*HZ; return 0; } @@ -1867,18 +1818,6 @@ static int mos7720_ioctl(struct tty_struct *tty, dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg); - - /* FIXME: These should be using the mode methods */ - case TIOCMBIS: - case TIOCMBIC: - dev_dbg(&port->dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", __func__); - return set_modem_info(mos7720_port, cmd, - (unsigned int __user *)arg); - - case TIOCGSERIAL: - dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); - return get_serial_info(mos7720_port, - (struct serial_struct __user *)arg); } return -ENOIOCTLCMD; @@ -2015,6 +1954,7 @@ static struct usb_serial_driver moschip7720_2port_driver = { .ioctl = mos7720_ioctl, .tiocmget = mos7720_tiocmget, .tiocmset = mos7720_tiocmset, + .get_serial = get_serial_info, .set_termios = mos7720_set_termios, .write = mos7720_write, .write_room = mos7720_write_room, diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index b42bad85097a..88828b4b8c44 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -1931,27 +1931,20 @@ static int mos7840_get_lsr_info(struct tty_struct *tty, * function to get information about serial port *****************************************************************************/ -static int mos7840_get_serial_info(struct moschip_port *mos7840_port, - struct serial_struct __user *retinfo) +static int mos7840_get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { - struct serial_struct tmp; - - if (mos7840_port == NULL) - return -1; - - memset(&tmp, 0, sizeof(tmp)); - - tmp.type = PORT_16550A; - tmp.line = mos7840_port->port->minor; - tmp.port = mos7840_port->port->port_number; - tmp.irq = 0; - tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; - tmp.baud_base = 9600; - tmp.close_delay = 5 * HZ; - tmp.closing_wait = 30 * HZ; + struct usb_serial_port *port = tty->driver_data; + struct moschip_port *mos7840_port = mos7840_get_port_private(port); - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + ss->type = PORT_16550A; + ss->line = mos7840_port->port->minor; + ss->port = mos7840_port->port->port_number; + ss->irq = 0; + ss->xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; + ss->baud_base = 9600; + ss->close_delay = 5 * HZ; + ss->closing_wait = 30 * HZ; return 0; } @@ -1982,13 +1975,6 @@ static int mos7840_ioctl(struct tty_struct *tty, dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); return mos7840_get_lsr_info(tty, argp); - case TIOCGSERIAL: - dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); - return mos7840_get_serial_info(mos7840_port, argp); - - case TIOCSSERIAL: - dev_dbg(&port->dev, "%s TIOCSSERIAL\n", __func__); - break; default: break; } @@ -2376,6 +2362,7 @@ static struct usb_serial_driver moschip7840_4port_device = { .calc_num_ports = mos7840_calc_num_ports, .probe = mos7840_probe, .ioctl = mos7840_ioctl, + .get_serial = mos7840_get_serial_info, .set_termios = mos7840_set_termios, .break_ctl = mos7840_break, .tiocmget = mos7840_tiocmget, diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index caa0746326fd..cb7aac9cd9e7 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -328,42 +328,23 @@ static int opticon_tiocmset(struct tty_struct *tty, return 0; } -static int get_serial_info(struct usb_serial_port *port, - struct serial_struct __user *serial) +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { - struct serial_struct tmp; - - memset(&tmp, 0x00, sizeof(tmp)); + struct usb_serial_port *port = tty->driver_data; /* fake emulate a 16550 uart to make userspace code happy */ - tmp.type = PORT_16550A; - tmp.line = port->minor; - tmp.port = 0; - tmp.irq = 0; - tmp.xmit_fifo_size = 1024; - tmp.baud_base = 9600; - tmp.close_delay = 5*HZ; - tmp.closing_wait = 30*HZ; - - if (copy_to_user(serial, &tmp, sizeof(*serial))) - return -EFAULT; + ss->type = PORT_16550A; + ss->line = port->minor; + ss->port = 0; + ss->irq = 0; + ss->xmit_fifo_size = 1024; + ss->baud_base = 9600; + ss->close_delay = 5*HZ; + ss->closing_wait = 30*HZ; return 0; } -static int opticon_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) -{ - struct usb_serial_port *port = tty->driver_data; - - switch (cmd) { - case TIOCGSERIAL: - return get_serial_info(port, - (struct serial_struct __user *)arg); - } - - return -ENOIOCTLCMD; -} - static int opticon_port_probe(struct usb_serial_port *port) { struct opticon_private *priv; @@ -404,7 +385,7 @@ static struct usb_serial_driver opticon_device = { .write_room = opticon_write_room, .throttle = usb_serial_generic_throttle, .unthrottle = usb_serial_generic_unthrottle, - .ioctl = opticon_ioctl, + .get_serial = get_serial_info, .tiocmget = opticon_tiocmget, .tiocmset = opticon_tiocmset, .process_read_urb = opticon_process_read_urb, diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e72ad9f81c73..e24ff16d4147 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -1966,7 +1966,8 @@ static struct usb_serial_driver option_1port_device = { .chars_in_buffer = usb_wwan_chars_in_buffer, .tiocmget = usb_wwan_tiocmget, .tiocmset = usb_wwan_tiocmset, - .ioctl = usb_wwan_ioctl, + .get_serial = usb_wwan_get_serial_info, + .set_serial = usb_wwan_set_serial_info, .attach = option_attach, .release = option_release, .port_probe = usb_wwan_port_probe, diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index e41f725ac7aa..a4e0d13fc121 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -808,29 +808,16 @@ static int pl2303_carrier_raised(struct usb_serial_port *port) return 0; } -static int pl2303_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) +static int pl2303_get_serial(struct tty_struct *tty, + struct serial_struct *ss) { - struct serial_struct ser; struct usb_serial_port *port = tty->driver_data; - switch (cmd) { - case TIOCGSERIAL: - memset(&ser, 0, sizeof ser); - ser.type = PORT_16654; - ser.line = port->minor; - ser.port = port->port_number; - ser.baud_base = 460800; - - if (copy_to_user((void __user *)arg, &ser, sizeof ser)) - return -EFAULT; - - return 0; - default: - break; - } - - return -ENOIOCTLCMD; + ss->type = PORT_16654; + ss->line = port->minor; + ss->port = port->port_number; + ss->baud_base = 460800; + return 0; } static void pl2303_set_break(struct usb_serial_port *port, bool enable) @@ -1016,7 +1003,7 @@ static struct usb_serial_driver pl2303_device = { .close = pl2303_close, .dtr_rts = pl2303_dtr_rts, .carrier_raised = pl2303_carrier_raised, - .ioctl = pl2303_ioctl, + .get_serial = pl2303_get_serial, .break_ctl = pl2303_break_ctl, .set_termios = pl2303_set_termios, .tiocmget = pl2303_tiocmget, diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index b61c2a9b6b11..f2fbe1ec9701 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -453,39 +453,19 @@ static void qt2_disconnect(struct usb_serial *serial) usb_kill_urb(serial_priv->read_urb); } -static int get_serial_info(struct usb_serial_port *port, - struct serial_struct __user *retinfo) -{ - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); - tmp.line = port->minor; - tmp.port = 0; - tmp.irq = 0; - tmp.xmit_fifo_size = port->bulk_out_size; - tmp.baud_base = 9600; - tmp.close_delay = 5*HZ; - tmp.closing_wait = 30*HZ; - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; - return 0; -} - -static int qt2_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) +static int get_serial_info(struct tty_struct *tty, + struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - switch (cmd) { - case TIOCGSERIAL: - return get_serial_info(port, - (struct serial_struct __user *)arg); - default: - break; - } - - return -ENOIOCTLCMD; + ss->line = port->minor; + ss->port = 0; + ss->irq = 0; + ss->xmit_fifo_size = port->bulk_out_size; + ss->baud_base = 9600; + ss->close_delay = 5*HZ; + ss->closing_wait = 30*HZ; + return 0; } static void qt2_process_status(struct usb_serial_port *port, unsigned char *ch) @@ -1013,7 +993,7 @@ static struct usb_serial_driver qt2_device = { .tiocmset = qt2_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, - .ioctl = qt2_ioctl, + .get_serial = get_serial_info, .set_termios = qt2_set_termios, }; diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 0900b47b5f57..f6aea9f1be1a 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -331,39 +331,19 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) return usb_serial_generic_open(tty, port); } -static int get_serial_info(struct usb_serial_port *port, - struct serial_struct __user *retinfo) -{ - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); - tmp.line = port->minor; - tmp.port = 0; - tmp.irq = 0; - tmp.xmit_fifo |
