From 5fac329f4bc44c653a1a6595a2832fd6639d681b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 23 Apr 2003 03:48:48 -0700 Subject: [PATCH] [PATCH] USB: pl2303: add support for new tty tiocmget and tiocmset functions. --- drivers/usb/serial/pl2303.c | 63 +++++++++++-------------------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index b341aad16a6ea..1d3ec53f94a06 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -124,6 +124,9 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs); static int pl2303_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count); static void pl2303_break_ctl(struct usb_serial_port *port,int break_state); +static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file); +static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file, + unsigned int set, unsigned int clear); static int pl2303_startup (struct usb_serial *serial); static void pl2303_shutdown (struct usb_serial *serial); @@ -143,6 +146,8 @@ static struct usb_serial_device_type pl2303_device = { .ioctl = pl2303_ioctl, .break_ctl = pl2303_break_ctl, .set_termios = pl2303_set_termios, + .tiocmget = pl2303_tiocmget, + .tiocmset = pl2303_tiocmset, .read_bulk_callback = pl2303_read_bulk_callback, .read_int_callback = pl2303_read_int_callback, .write_bulk_callback = pl2303_write_bulk_callback, @@ -490,51 +495,35 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp) } -static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value) +static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file, + unsigned int set, unsigned int clear) { struct pl2303_private *priv = usb_get_serial_port_data(port); - unsigned int arg; u8 control; - if (copy_from_user(&arg, value, sizeof(int))) - return -EFAULT; - spin_lock (&priv->lock); - switch (cmd) { - case TIOCMBIS: - if (arg & TIOCM_RTS) - priv->line_control |= CONTROL_RTS; - if (arg & TIOCM_DTR) - priv->line_control |= CONTROL_DTR; - break; - - case TIOCMBIC: - if (arg & TIOCM_RTS) - priv->line_control &= ~CONTROL_RTS; - if (arg & TIOCM_DTR) - priv->line_control &= ~CONTROL_DTR; - break; - - case TIOCMSET: - /* turn off RTS and DTR and then only turn - on what was asked to */ - priv->line_control &= ~(CONTROL_RTS | CONTROL_DTR); - priv->line_control |= ((arg & TIOCM_RTS) ? CONTROL_RTS : 0); - priv->line_control |= ((arg & TIOCM_DTR) ? CONTROL_DTR : 0); - break; - } + if (set & TIOCM_RTS) + priv->line_control |= CONTROL_RTS; + if (set & TIOCM_DTR) + priv->line_control |= CONTROL_DTR; + if (clear & TIOCM_RTS) + priv->line_control &= ~CONTROL_RTS; + if (clear & TIOCM_DTR) + priv->line_control &= ~CONTROL_DTR; control = priv->line_control; spin_unlock (&priv->lock); return set_control_lines (port->serial->dev, control); } -static int get_modem_info (struct usb_serial_port *port, unsigned int *value) +static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file) { struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned int mcr; unsigned int result; + dbg("%s (%d)", __FUNCTION__, port->number); + spin_lock (&priv->lock); mcr = priv->line_control; spin_unlock (&priv->lock); @@ -544,9 +533,7 @@ static int get_modem_info (struct usb_serial_port *port, unsigned int *value) dbg("%s - result = %x", __FUNCTION__, result); - if (copy_to_user(value, &result, sizeof(int))) - return -EFAULT; - return 0; + return result; } static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) @@ -554,17 +541,6 @@ static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsign dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd); switch (cmd) { - - case TIOCMGET: - dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); - return get_modem_info (port, (unsigned int *)arg); - - case TIOCMBIS: - case TIOCMBIC: - case TIOCMSET: - dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, port->number); - return set_modem_info(port, cmd, (unsigned int *) arg); - default: dbg("%s not supported = 0x%04x", __FUNCTION__, cmd); break; @@ -573,7 +549,6 @@ static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsign return -ENOIOCTLCMD; } - static void pl2303_break_ctl (struct usb_serial_port *port, int break_state) { struct usb_serial *serial = port->serial; -- 2.53.0